import { _decorator, Component, Node } from 'cc'; import { Http } from '../core/net/Http'; import { WindowManager } from '../core/ui/window/WindowManager'; import { WindowOpenMode } from '../core/ui/window/WindowOpenMode'; import { g } from '../Data/g'; const { ccclass, property } = _decorator; /** 新手引导 */ @ccclass('NoviceWindow') export class NoviceWindow extends Component { @property({ type: [Node], tooltip: "新手引导节点集合" }) novices: Array = []; // @property({ type: Window, tooltip: "获取窗口" }) getWindow: Window; @property({ type: Http, tooltip: "http组件" }) http: Http; public static isNovicing = false; public static isOpenLvRedpacket = false; public static isLastStep = false; private index = 0; start() { NoviceWindow.isNovicing = true; for (let i = 0; i < this.novices.length; i++) { this.novices[i].active = i == 0; } this.index = 0; } update() { if (!NoviceWindow.isNovicing) { this.node.active = false; this.node.destroy(); } if (NoviceWindow.isOpenLvRedpacket) { this.novices[this.index].active = false; NoviceWindow.isOpenLvRedpacket = false; } if (NoviceWindow.isLastStep) { NoviceWindow.isLastStep = false; this.next(); } else { switch (this.index) { case 0: if (g.gameData.getMyLocalData(g.userData.id).myLocalGenerals.length > 1) { this.next(); } break; case 1: if (g.userData.lv == 2) { this.next(); } break; } } } /**下一步 */ public next(): void { this.novices[this.index].active = false; if (this.novices[this.index + 1]) { this.novices[++this.index].active = true; } else { this.node.active = false; this.node.destroy(); } } /**打开等级红包 */ public goTowithDraw(): void { WindowManager.open("Prefabs/Withdraw/Withdraw", WindowOpenMode.CloseAndCover); this.next(); } }