GuideSystem.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. if (!cc.sys.isNative) {
  10. this.crtGuideID = 0;//测试无限新手引导
  11. gData.gameData.setProp(GameProp.levelNum, 0);
  12. }
  13. if (this.crtGuideID >= 9999) {
  14. mk.console.log("新手引导已做完");
  15. return;
  16. }
  17. if (id >= this.crtGuideID && this.crtGuideID > 0) {
  18. mk.console.log("当前引导已做过:" + id);
  19. return;
  20. }
  21. gData.guideData.crtID = id;
  22. this.crtGuideID = id;
  23. mk.ui.openPanel("module/guide/guide");
  24. this.setGuideID(this.crtGuideID++);
  25. }
  26. /** 开启一个引导后直接默认已完成 */
  27. private setGuideID(id: number) {
  28. let guide = gData.guideData.getGuidesByID(id);
  29. if (guide == null) {
  30. id = 9999;
  31. }
  32. gData.gameData.setProp(GameProp.guideID, id);
  33. }
  34. public close() {
  35. this.crtGuideID++;
  36. }
  37. /**
  38. * 引导是否完成
  39. * @returns true 已完成
  40. */
  41. public isGuideComplete(): Boolean {
  42. if (!this.crtGuideID || this.crtGuideID === 999) {
  43. return true;
  44. } else {
  45. return false;
  46. }
  47. }
  48. }