GuideSystem.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. if (this.crtGuideID >= 9999) {
  19. mk.console.log("新手引导已做完");
  20. return;
  21. }
  22. if (id <= this.crtGuideID && this.crtGuideID > 0) {
  23. mk.console.log("当前引导已做过:" + id);
  24. return;
  25. }
  26. gData.guideData.crtID = id;
  27. this.crtGuideID = id;
  28. mk.ui.openPanel("module/guide/guide", OpenActionType.normal, this.ui);
  29. this.setGuideID(this.crtGuideID++);
  30. }
  31. /** 开启一个引导后直接默认已完成 */
  32. private setGuideID(id: number) {
  33. if (id == 4) {
  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. }