GuideSystem.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { GameProp } from "../../game/data/GameData";
  2. /**
  3. * 新手引导模块
  4. */
  5. export default class GuideSystem {
  6. private crtGuideID: number;
  7. public open(id) {
  8. this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
  9. this.setGuideID(this.crtGuideID++);
  10. if (id == 9999) {
  11. mk.console.log("新手引导已做完");
  12. return;
  13. }
  14. if (id >= this.crtGuideID && this.crtGuideID > 0) {
  15. mk.console.log("当前引导已做过:" + id);
  16. return;
  17. }
  18. gData.guideData.crtID = id;
  19. this.crtGuideID = id;
  20. mk.ui.openPanel("module/guide/guide");
  21. }
  22. /** 开启一个引导后直接默认已完成 */
  23. private setGuideID(id: number) {
  24. let guide = gData.guideData.getGuidesByID(id);
  25. if (guide == null) {
  26. id = 9999;
  27. }
  28. gData.gameData.setProp(GameProp.guideID, id);
  29. }
  30. public close() {
  31. this.crtGuideID++;
  32. }
  33. /**
  34. * 引导是否完成
  35. * @returns true 已完成
  36. */
  37. public isGuideComplete(): Boolean {
  38. if (!this.crtGuideID || this.crtGuideID === 999) {
  39. return true;
  40. } else {
  41. return false;
  42. }
  43. }
  44. }