GuideSystem.ts 1.8 KB

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