GuideSystem.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { DataEventId, GameProp } from "../../game/data/GameData";
  2. import { OpenActionType } from "./UISystem";
  3. /**
  4. * 新手引导模块
  5. */
  6. export default class GuideSystem {
  7. public crtGuideID: number;
  8. public ui: cc.Node;
  9. public open(id) {
  10. this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
  11. // //测试永远新手引导,永远第一关
  12. // if (!cc.sys.isNative) {
  13. // this.crtGuideID = 1;
  14. // }
  15. // //test
  16. // this.crtGuideID = 0;
  17. if (this.crtGuideID >= 9999) {
  18. mk.console.log("新手引导已做完");
  19. return;
  20. }
  21. if (id <= this.crtGuideID && this.crtGuideID > 0) {
  22. mk.console.log("当前引导已做过:" + id);
  23. return;
  24. }
  25. gData.guideData.crtID = id;
  26. this.crtGuideID = id;
  27. mk.ui.openPanel("module/guide/guide", OpenActionType.normal, this.ui);
  28. this.setGuideID(this.crtGuideID++);
  29. }
  30. /** 开启一个引导后直接默认已完成 */
  31. private setGuideID(id: number) {
  32. if (id == 4) {
  33. id = 9999;
  34. mk.data.sendXYEvent("guide_end", "新手引导结束");
  35. }
  36. gData.gameData.setProp(GameProp.guideID, id);
  37. }
  38. public close() {
  39. this.crtGuideID++;
  40. }
  41. /**
  42. * 引导是否完成
  43. * @returns true 已完成
  44. */
  45. public isGuideComplete(): boolean {
  46. if (!this.crtGuideID || this.crtGuideID === 9999) {
  47. return true;
  48. } else {
  49. return false;
  50. }
  51. }
  52. /**
  53. * 当前是否正在引导
  54. * @returns
  55. */
  56. public isGuiding(): boolean {
  57. return mk.ui.getCurOnPanel("guide") != null;
  58. }
  59. }