c513e8a2-25e1-462f-9e02-8fddca9b38f6.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. "use strict";
  2. cc._RF.push(module, 'c513eiiJeFGL54Cj93Kmzj2', 'ConfigDataMgr');
  3. // Script/Framework/Manager/ConfigDataMgr.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.ConfigDataMgr = void 0;
  20. var Singleton_1 = require("../Utils/Singleton");
  21. var NumberUtil_1 = require("../Utils/NumberUtil");
  22. var App_1 = require("../../Manager/App");
  23. var EnumDefine_1 = require("../Const/EnumDefine");
  24. /**
  25. * 配置管理类
  26. */
  27. var ConfigDataMgr = /** @class */ (function (_super) {
  28. __extends(ConfigDataMgr, _super);
  29. function ConfigDataMgr() {
  30. return _super.call(this) || this;
  31. }
  32. Object.defineProperty(ConfigDataMgr.prototype, "attrs", {
  33. get: function () { return this._config["attr"]; },
  34. enumerable: false,
  35. configurable: true
  36. });
  37. Object.defineProperty(ConfigDataMgr.prototype, "consumes", {
  38. get: function () { return this._config["consume"]; },
  39. enumerable: false,
  40. configurable: true
  41. });
  42. Object.defineProperty(ConfigDataMgr.prototype, "exps", {
  43. get: function () { return this._config["exp"]; },
  44. enumerable: false,
  45. configurable: true
  46. });
  47. Object.defineProperty(ConfigDataMgr.prototype, "tasks", {
  48. get: function () { return this._config["task"]; },
  49. enumerable: false,
  50. configurable: true
  51. });
  52. Object.defineProperty(ConfigDataMgr.prototype, "fuli_days", {
  53. get: function () { return this._config["fuli_day"]; },
  54. enumerable: false,
  55. configurable: true
  56. });
  57. Object.defineProperty(ConfigDataMgr.prototype, "fuli_watchs", {
  58. // private get fuli_times(): fuli_time[] { return this._config["fuli_time"] as fuli_time[]; }
  59. get: function () { return this._config["fuli_watch"]; },
  60. enumerable: false,
  61. configurable: true
  62. });
  63. Object.defineProperty(ConfigDataMgr.prototype, "nicks", {
  64. get: function () { return this._config["nick"]; },
  65. enumerable: false,
  66. configurable: true
  67. });
  68. Object.defineProperty(ConfigDataMgr.prototype, "configs", {
  69. get: function () {
  70. if (this._config)
  71. return this._config;
  72. else {
  73. console.log("config配置文件还未读取!!");
  74. return null;
  75. }
  76. },
  77. set: function (res) {
  78. console.log("解析配置文件");
  79. if (!res)
  80. return;
  81. for (var i = 0; i < res.length; i++) {
  82. var arr = [];
  83. var json = res[i]["json"];
  84. for (var j = 0; j < json.length; j++) {
  85. arr.push(json[j]);
  86. }
  87. this._config[res[i].name] = arr;
  88. }
  89. },
  90. enumerable: false,
  91. configurable: true
  92. });
  93. /** 导入配置文件 */
  94. ConfigDataMgr.prototype.loadConfigs = function (cb) {
  95. console.log("读取配置文件");
  96. this._config = {};
  97. var url = "configs";
  98. var self = this;
  99. cc.loader.loadResDir(url, cc.Asset, function (err, res) {
  100. self.configs = res;
  101. console.log("配置文件解析完成");
  102. console.log(self.attrs);
  103. App_1.App.DataManager.init();
  104. cb();
  105. });
  106. };
  107. /** 随机生成昵称 */
  108. ConfigDataMgr.prototype.getNick = function () {
  109. var range = this.nicks.length;
  110. return this.nicks[NumberUtil_1.NumberUtil.getRandomInt(0, range)];
  111. };
  112. /** 获取消耗列表 */
  113. ConfigDataMgr.prototype.getConsumeList = function () {
  114. return this.consumes;
  115. };
  116. /** 获取任务列表 */
  117. ConfigDataMgr.prototype.getTaskList = function () {
  118. return this.tasks;
  119. };
  120. /** 获取福利Day列表 */
  121. ConfigDataMgr.prototype.getFuLiDayList = function () {
  122. return this.fuli_days;
  123. };
  124. /** 获取福利Watch列表 */
  125. ConfigDataMgr.prototype.getFuLiWatchList = function () {
  126. return this.fuli_watchs;
  127. };
  128. /** 获取指定狗的初始属性 */
  129. ConfigDataMgr.prototype.getBeginingAttr = function (prop) {
  130. var result;
  131. for (var i = 0; i < this.attrs.length; i++) {
  132. var item = this.attrs[i];
  133. if (item.prop == EnumDefine_1.EConfigAttrProp[prop]) {
  134. result = item;
  135. break;
  136. }
  137. }
  138. return result;
  139. };
  140. /** 获取年龄段 */
  141. ConfigDataMgr.prototype.getAgeGroup = function (level) {
  142. return level < 11 ? EnumDefine_1.EAgeGroup.PERIOD_KIDS
  143. : level < 31 ? EnumDefine_1.EAgeGroup.PERIOD_YOUNG : EnumDefine_1.EAgeGroup.PERIOD_GROWNUP;
  144. };
  145. /** 获取指定狗的成长属性 */
  146. ConfigDataMgr.prototype.getGrowingAttr = function (level) {
  147. var prop = level < 11 ? EnumDefine_1.EConfigAttrProp.cq_childhood
  148. : level < 31 ? EnumDefine_1.EConfigAttrProp.cq_youth : EnumDefine_1.EConfigAttrProp.cq_adulthood;
  149. var result;
  150. for (var i = 0; i < this.attrs.length; i++) {
  151. var item = this.attrs[i];
  152. if (item.prop == EnumDefine_1.EConfigAttrProp[prop]) {
  153. result = item;
  154. break;
  155. }
  156. }
  157. return result;
  158. };
  159. /** 通过亲密度等级获取升级所需经验 */
  160. ConfigDataMgr.prototype.getExpByLv = function (lv) {
  161. for (var i = 0; i < this.exps.length; i++) {
  162. var item = this.exps[i];
  163. if (item.lv == lv) {
  164. return item.exp;
  165. }
  166. }
  167. return -1;
  168. };
  169. Object.defineProperty(ConfigDataMgr.prototype, "DOG_MAX_LEVEL", {
  170. /** 获取狗的最高等级 */
  171. get: function () {
  172. return this.exps.length;
  173. },
  174. enumerable: false,
  175. configurable: true
  176. });
  177. /** 获取每日签到奖励 */
  178. ConfigDataMgr.prototype.getFuLiDayReward = function (day) {
  179. for (var i = 0; i < this.fuli_days.length; i++) {
  180. if (this.fuli_days[i].day == day)
  181. return this.fuli_days[i].reward;
  182. }
  183. console.log("出错了");
  184. };
  185. return ConfigDataMgr;
  186. }(Singleton_1.Singleton));
  187. exports.ConfigDataMgr = ConfigDataMgr;
  188. cc._RF.pop();