GuideData.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Data } from "../../../mk/data/Data";
  2. import GuideVO from "../../module/guide/GuideVO";
  3. /**
  4. * @description 新手引导
  5. * @author 邹勇
  6. */
  7. export class GuideData {
  8. /** 新手引导数据 */
  9. public data: Map<number, GuideVO[]>;
  10. /** 当前引导id */
  11. public crtID: number = null;
  12. public async init() {
  13. let config = gData.gameData.configs.Guide
  14. // //test
  15. // config = null;
  16. if (!config) {
  17. let result = await mk.loader.load("data/guide_data", cc.JsonAsset);
  18. if (result && result.json) {
  19. config = result.json;
  20. }
  21. cc.log('无远程引导数据,使用本地测试数据');
  22. }
  23. this.data = new Map<number, GuideVO[]>();
  24. let arr = [];
  25. let id = 1;
  26. for (let i = 0; i < config.length; i++) {
  27. let guide = {} as GuideVO;
  28. let o = config[i];
  29. let a = o.id.split("_");
  30. guide.id = parseInt(a[0]);
  31. guide.step = parseInt(a[1]);
  32. guide.trigger = o.trigger;
  33. guide.tr_num = o.trNum;
  34. guide.tr_form = o.trForm;
  35. guide.dialog = o.dialog;
  36. guide.dialog_pos = o.dialogPos;
  37. guide.dialog_pos1 = o.dialogPos1;
  38. guide.dialog_alignment = o.dialogAlignment;
  39. guide.display_rect = o.displayRect;
  40. guide.click_rect = o.clickRect;
  41. guide.finger = o.finger;
  42. guide.lag_next = parseFloat(o.lagNext);
  43. guide.display_type = parseInt(o.trNum);
  44. if (id != guide.id) {
  45. this.data.set(id, arr);
  46. arr = [];
  47. id = guide.id;
  48. }
  49. arr.push(guide);
  50. }
  51. this.data.set(id, arr);
  52. }
  53. public getGuidesByID(id): GuideVO[] {
  54. return this.data.get(id);
  55. }
  56. }