| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import GamePlay from "../../before/GamePlay";
- import { DataEventId, GameProp } from "../../game/data/GameData";
- import { OpenActionType } from "./UISystem";
- /**
- * 新手引导模块
- */
- export default class GuideSystem {
- public crtGuideID: number;
- public ui: cc.Node;
- public open(id) {
- if (id == 3) {
- if (!gData.guideToWxData.guideToWxSwith) {
- return;
- }
- let can = mk.storage.getStorage('canShowGuideToWx') == '1';
- if (!can) {
- return
- }
- let state = gData.gameData.getProp(GameProp.guideToWx);
- if (!state) {
- gData.gameData.setProp(GameProp.guideToWx, 1);
- gData.guideToWxData.init_state = true;
- mk.ui.closeAllUI();
- if (GamePlay.Inst.node && GamePlay.Inst.node.active) {
- GamePlay.Inst.restart();//退出不扣体力
- GamePlay.Inst.node.active = false;
- }
- }
- }
- this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
- // //test
- // if (this.crtGuideID > id)
- // return;
- //测试永远新手引导,永远第一关
- 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 == 5) {
- 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;
- }
- }
|