GuideSystem.ts 2.1 KB

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