| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { DataEventId, GameProp } from "../../game/data/GameData";
- import { OpenActionType } from "./UISystem";
- /**
- * 新手引导模块
- */
- export default class GuideSystem {
- private crtGuideID: number;
- public ui: cc.Node;
- public open(id) {
- if (gData.gameData.funOpenData['6'] != 1) {
- this.crtGuideID = 9999;
- gData.gameData.setProp(GameProp.guideID, this.crtGuideID);
- }
- else {
- this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
- }
- //测试永远新手引导,永远第一关
- if (!cc.sys.isNative) {
- this.crtGuideID = 1;
- gData.gameData.setProp(GameProp.levelNum, 0);
- }
- if (this.crtGuideID >= 9999) {
- mk.console.log("新手引导已做完");
- return;
- }
- if (id <= this.crtGuideID && this.crtGuideID > 0) {
- mk.console.log("当前引导已做过:" + id);
- return;
- }
- 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) {
- let guide = gData.guideData.getGuidesByID(id);
- if (id == 2) {
- 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;
- }
- }
|