GuideSystem.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }
  29. /** 开启一个引导后直接默认已完成 */
  30. private setGuideID(id: number) {
  31. let guide = gData.guideData.getGuidesByID(id);
  32. if (guide == null) {
  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. }