GuideSystem.ts 1.6 KB

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