import { _decorator, Component, Node, director, Enum, Vec3, v3, Animation } from 'cc'; import { Window } from '../core/ui/window/Window'; import { WindowOpenMode } from '../core/ui/window/WindowOpenMode'; import { WindowSystem } from '../core/ui/window/WindowSystem'; const { ccclass, property } = _decorator; /** * 引导类型 */ export enum GuideType { Train, Marshal } /** * 引导 * @author 孙雄 */ @ccclass('Guide') export class Guide extends Component { @property({ tooltip: "类型列表", type: [Node] }) public typeList: Node[] = []; private type: GuideType; private static guides: Map = new Map(); start() { this.type = this.getComponent(Window).params[0]; for (let i = 0; i < this.typeList.length; i++) { this.typeList[i].active = i == this.type; } Guide.guides.has(this.type) && Guide.close(this.type); Guide.guides.set(this.type, this); this.scheduleOnce(() => { Guide.close(this.type); }, 10); } public static close(type: GuideType) { if (Guide.guides.has(type)) { if (Guide.guides.get(type).node) Guide.guides.get(type).getComponent(Window).forceClose(); Guide.guides.delete(type); } } public static create(type: GuideType) { WindowSystem.open('prefabs/ui/guide/guide', WindowOpenMode.CloseAndAdd, [type]); } }