GuideSystem.ts 2.0 KB

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