DataMsrBase.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. var t = require;
  2. var e = module;
  3. var s = exports;
  4. var o =
  5. (this && this.__awaiter) ||
  6. function (t, n, r, l) {
  7. return new (r = r || Promise)(function (i, e) {
  8. function s(t) {
  9. try {
  10. a(l.next(t));
  11. } catch (t) {
  12. e(t);
  13. }
  14. }
  15. function o(t) {
  16. try {
  17. a(l.throw(t));
  18. } catch (t) {
  19. e(t);
  20. }
  21. }
  22. function a(t) {
  23. var e;
  24. t.done
  25. ? i(t.value)
  26. : ((e = t.value) instanceof r
  27. ? e
  28. : new r(function (t) {
  29. t(e);
  30. })
  31. ).then(s, o);
  32. }
  33. a((l = l.apply(t, n || [])).next());
  34. });
  35. };
  36. Object.defineProperty(s, "__esModule", {value: !0}), (s.CsvDataList = s.CsvDataMap = s.CONFIG_FILE_DIR = void 0);
  37. const a = t("App");
  38. (s.CONFIG_FILE_DIR = ""),
  39. (s.default = class {
  40. constructor(t, e, i) {
  41. (this._class = t), (this.csvFileName = e), (this.indexKey = i), (this.datas = {}), (this.dataCnt = 0);
  42. }
  43. loadFile(i) {
  44. return o(this, void 0, void 0, function* () {
  45. try {
  46. var t = yield a.default.ResManager.loadInBundle("config", s.CONFIG_FILE_DIR + i, cc.TextAsset),
  47. e = t.text;
  48. cc.assetManager.releaseAsset(t);
  49. } catch (t) {
  50. Log.error("加载配置文件出错:", i, t);
  51. }
  52. return e.replace(/\r\n/g, "\n");
  53. });
  54. }
  55. load() {
  56. return o(this, void 0, void 0, function* () {
  57. let s = (yield this.loadFile(this.csvFileName)).split(/\n/),
  58. o = s[0].split(","),
  59. a = (s[1].split(","), s[2].split(",")),
  60. t = s.length;
  61. for (let i = 3; i < t; i++)
  62. if (s[i]) {
  63. let t = s[i].split(","),
  64. e = this.datas[t[0]];
  65. e || ((e = new this._class()), (this.datas[t[0]] = e), this.dataCnt++), e.$parseData(t, o, a);
  66. }
  67. });
  68. }
  69. getAllDatas() {
  70. return this.datas;
  71. }
  72. getData(t) {
  73. t = this.datas[t];
  74. return null == t ? null : t;
  75. }
  76. }),
  77. (s.CsvDataMap = class {
  78. constructor(t, e = 1) {
  79. (this._class = t), (this.keyIndex = e), (this.datas = {}), (this.id = null), (this.dataCnt = 0);
  80. }
  81. $parseData(t, e, i) {
  82. let s = this.datas[t[this.keyIndex]];
  83. s || ((s = new this._class()), (this.datas[t[this.keyIndex]] = s), this.dataCnt++), s.$parseData(t, e, i);
  84. }
  85. createAwardLevel() {}
  86. getData(t) {
  87. return this.datas[t];
  88. }
  89. getAllData() {
  90. return this.datas;
  91. }
  92. getCount() {
  93. return this.dataCnt;
  94. }
  95. }),
  96. (s.CsvDataList = class {
  97. constructor(t) {
  98. (this._class = t), (this.awardLevel = []), (this.datas = []), (this.id = null), (this.dataCnt = 0);
  99. }
  100. $parseData(t, e, i) {
  101. let s = new this._class();
  102. s.$parseData(t, e, i), this.datas.push(s), (this.dataCnt = this.datas.length);
  103. }
  104. createAwardLevel() {}
  105. getData(t) {
  106. return this.datas[t];
  107. }
  108. getAllData() {
  109. return this.datas;
  110. }
  111. getCount() {
  112. return this.dataCnt;
  113. }
  114. });