GuideSystem.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { DataEventId, GameProp } from "../../game/data/GameData";
  2. import { OpenActionType } from "./UISystem";
  3. /**
  4. * 新手引导模块
  5. */
  6. export default class GuideSystem {
  7. public crtGuideID: number;
  8. public ui: cc.Node;
  9. public open(id) {
  10. if (gData.gameData.configs.ServerConfig.NewUserGuide == '0') {
  11. return
  12. }
  13. this.crtGuideID = gData.gameData.getProp(GameProp.guideID);
  14. if (this.crtGuideID == undefined) {
  15. this.crtGuideID = 0;
  16. }
  17. // //测试永远新手引导,永远第一关
  18. // if (!cc.sys.isNative) {
  19. // this.crtGuideID = 1;
  20. // }
  21. // //test
  22. // this.crtGuideID = 0
  23. if (this.crtGuideID >= 9999) {
  24. mk.console.log("新手引导已做完");
  25. return;
  26. }
  27. if (id <= this.crtGuideID && this.crtGuideID > 0) {
  28. mk.console.log("当前引导已做过:" + id);
  29. return;
  30. }
  31. gData.guideData.crtID = id;
  32. this.crtGuideID = id;
  33. mk.ui.openPanel("module/guide/guide", OpenActionType.normal, this.ui);
  34. this.setGuideID(this.crtGuideID++);
  35. }
  36. /** 开启一个引导后直接默认已完成 */
  37. private setGuideID(id: number) {
  38. if (id == 5) {
  39. id = 9999;
  40. mk.data.sendXYEvent("guide_end", "新手引导结束");
  41. }
  42. gData.gameData.setProp(GameProp.guideID, id);
  43. }
  44. public close() {
  45. this.crtGuideID++;
  46. }
  47. /**
  48. * 引导是否完成
  49. * @returns true 已完成
  50. */
  51. public isGuideComplete(): boolean {
  52. if (!this.crtGuideID || this.crtGuideID === 9999) {
  53. return true;
  54. } else {
  55. return false;
  56. }
  57. }
  58. /**
  59. * 当前是否正在引导
  60. * @returns
  61. */
  62. public isGuiding(): boolean {
  63. return mk.ui.getCurOnPanel("guide") != null;
  64. }
  65. }