GuideSystem.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.crtGuideID = 0;//测试无限新手引导
  10. if (this.crtGuideID >= 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. this.setGuideID(this.crtGuideID++);
  22. }
  23. /** 开启一个引导后直接默认已完成 */
  24. private setGuideID(id: number) {
  25. let guide = gData.guideData.getGuidesByID(id);
  26. if (guide == null) {
  27. id = 9999;
  28. }
  29. gData.gameData.setProp(GameProp.guideID, id);
  30. }
  31. public close() {
  32. this.crtGuideID++;
  33. }
  34. /**
  35. * 引导是否完成
  36. * @returns true 已完成
  37. */
  38. public isGuideComplete(): Boolean {
  39. if (!this.crtGuideID || this.crtGuideID === 999) {
  40. return true;
  41. } else {
  42. return false;
  43. }
  44. }
  45. }