GuideSystem.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. }
  35. gData.gameData.setProp(GameProp.guideID, id);
  36. }
  37. public close() {
  38. this.crtGuideID++;
  39. }
  40. /**
  41. * 引导是否完成
  42. * @returns true 已完成
  43. */
  44. public isGuideComplete(): boolean {
  45. if (!this.crtGuideID || this.crtGuideID === 999) {
  46. return true;
  47. } else {
  48. return false;
  49. }
  50. }
  51. /**
  52. * 当前是否正在引导
  53. * @returns
  54. */
  55. public isGuiding():boolean{
  56. return mk.ui.getCurOnPanel("guide") != null;
  57. }
  58. }