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