GuideSystem.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 curDes = '';
  10. //当前进行到哪一步的拼接字符串
  11. public curGuideIdStr: string = null;
  12. //判断继续当前步骤的回调函数
  13. public continueCallBack: Function = null;
  14. public open(id, curDes = '') {
  15. // return;
  16. if (gData.gameData.configs.ServerConfig.NewUserGuide == '0') {
  17. return false;
  18. }
  19. this.curDes = curDes;
  20. this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
  21. if (this.crtGuideID == undefined) {
  22. this.crtGuideID = 0;
  23. }
  24. // //测试永远新手引导,永远第一关
  25. // if (!cc.sys.isNative) {
  26. // this.crtGuideID = 1;
  27. // }
  28. //test
  29. // this.crtGuideID = 0
  30. if (this.crtGuideID >= 9999) {
  31. mk.console.log("新手引导已做完");
  32. return false;
  33. }
  34. if (id <= this.crtGuideID && this.crtGuideID > 0) {
  35. mk.console.log("当前引导已做过:" + id);
  36. return false;
  37. }
  38. gData.guideData.crtID = id;
  39. this.crtGuideID = id;
  40. mk.ui.openPanel("module/guide/guide", OpenActionType.normal, this.ui);
  41. this.setGuideID(this.crtGuideID++);
  42. return true;
  43. }
  44. /** 开启一个引导后直接默认已完成 */
  45. private setGuideID(id: number) {
  46. if (id == 14) {
  47. id = 9999;
  48. mk.data.sendXYEvent("guide_end", "新手引导结束");
  49. }
  50. gData.gameData.setProp(GameProp.guideID, id);
  51. }
  52. public close() {
  53. this.crtGuideID++;
  54. this.crtGuideID = -1;
  55. }
  56. /**
  57. * 引导是否完成
  58. * @returns true 已完成
  59. */
  60. public isGuideComplete(): boolean {
  61. let id = gData.gameData.getProp(GameProp.guideID);
  62. if (!this.crtGuideID || id === 9999) {
  63. return true;
  64. } else {
  65. return false;
  66. }
  67. }
  68. /**
  69. * 当前是否正在引导
  70. * @returns
  71. */
  72. public isGuiding(): boolean {
  73. return mk.ui.getCurOnPanel("guide") != null;
  74. }
  75. public getCurGuideIdString() {
  76. return this.curGuideIdStr;
  77. }
  78. public next() {
  79. mk.event.emit("next");
  80. }
  81. }