import { DataEventId, GameProp } from "../../game/data/GameData"; import { OpenActionType } from "./UISystem"; /** * 新手引导模块 */ export default class GuideSystem { public crtGuideID: number; public ui: cc.Node; public curDes = ''; //当前进行到哪一步的拼接字符串 public curGuideIdStr: string = null; //判断继续当前步骤的回调函数 public continueCallBack: Function = null; public open(id, curDes = '') { if (gData.gameData.configs.ServerConfig.NewUserGuide == '0') { return false; } this.curDes = curDes; this.crtGuideID = gData.gameData.getProp(GameProp.guideID); if (this.crtGuideID == undefined) { this.crtGuideID = 0; } // //测试永远新手引导,永远第一关 // if (!cc.sys.isNative) { // this.crtGuideID = 1; // } //test // this.crtGuideID = 0 if (this.crtGuideID >= 9999) { mk.console.log("新手引导已做完"); return false; } if (id <= this.crtGuideID && this.crtGuideID > 0) { mk.console.log("当前引导已做过:" + id); return false; } gData.guideData.crtID = id; this.crtGuideID = id; mk.ui.openPanel("module/guide/guide", OpenActionType.normal, this.ui); this.setGuideID(this.crtGuideID++); return true; } /** 开启一个引导后直接默认已完成 */ private setGuideID(id: number) { if (id == 12) { id = 9999; mk.data.sendXYEvent("guide_end", "新手引导结束"); } gData.gameData.setProp(GameProp.guideID, id); } public close() { this.crtGuideID++; } /** * 引导是否完成 * @returns true 已完成 */ public isGuideComplete(): boolean { if (!this.crtGuideID || this.crtGuideID === 9999) { return true; } else { return false; } } /** * 当前是否正在引导 * @returns */ public isGuiding(): boolean { return mk.ui.getCurOnPanel("guide") != null; } public getCurGuideIdString() { return this.curGuideIdStr; } }