| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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) {
- console.log('BBB 111111 ', gData.guideToWxData.guideToWxSwith)
- if (!gData.guideToWxData.guideToWxSwith) {
- return;
- }
- let can = (mk.storage.getStorage('canShowGuideToWx') == '1');
- console.log('BBB 222222 ', can)
- if (!can) {
- return
- }
- let state = gData.gameData.getProp(GameProp.guideToWx);
- console.log('BBB 3333333 ', state)
- if (!state) {
- console.log('BBB 444444 ')
- gData.gameData.setProp(GameProp.guideToWx, 1);
- gData.guideToWxData.init_state = true;
- mk.ui.closeAllUI();
- if (GamePlay.Inst && 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) {
- 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;
- }
- }
|