GuideSystem.ts 1.4 KB

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