GuideSystem.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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
  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;
  28. }
  29. if (id <= this.crtGuideID && this.crtGuideID > 0) {
  30. mk.console.log("当前引导已做过:" + id);
  31. return;
  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. }
  38. /** 开启一个引导后直接默认已完成 */
  39. private setGuideID(id: number) {
  40. if (id == 4) {
  41. id = 9999;
  42. mk.data.sendXYEvent("guide_end", "新手引导结束");
  43. }
  44. gData.gameData.setProp(GameProp.guideID, id);
  45. }
  46. public close() {
  47. this.crtGuideID++;
  48. }
  49. /**
  50. * 引导是否完成
  51. * @returns true 已完成
  52. */
  53. public isGuideComplete(): boolean {
  54. if (!this.crtGuideID || this.crtGuideID === 9999) {
  55. return true;
  56. } else {
  57. return false;
  58. }
  59. }
  60. /**
  61. * 当前是否正在引导
  62. * @returns
  63. */
  64. public isGuiding(): boolean {
  65. return mk.ui.getCurOnPanel("guide") != null;
  66. }
  67. }