"use strict"; cc._RF.push(module, 'c513eiiJeFGL54Cj93Kmzj2', 'ConfigDataMgr'); // Script/Framework/Manager/ConfigDataMgr.ts "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigDataMgr = void 0; var Singleton_1 = require("../Utils/Singleton"); var NumberUtil_1 = require("../Utils/NumberUtil"); var App_1 = require("../../Manager/App"); var EnumDefine_1 = require("../Const/EnumDefine"); /** * 配置管理类 */ var ConfigDataMgr = /** @class */ (function (_super) { __extends(ConfigDataMgr, _super); function ConfigDataMgr() { return _super.call(this) || this; } Object.defineProperty(ConfigDataMgr.prototype, "attrs", { get: function () { return this._config["attr"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "consumes", { get: function () { return this._config["consume"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "exps", { get: function () { return this._config["exp"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "tasks", { get: function () { return this._config["task"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "fuli_days", { get: function () { return this._config["fuli_day"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "fuli_watchs", { // private get fuli_times(): fuli_time[] { return this._config["fuli_time"] as fuli_time[]; } get: function () { return this._config["fuli_watch"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "nicks", { get: function () { return this._config["nick"]; }, enumerable: false, configurable: true }); Object.defineProperty(ConfigDataMgr.prototype, "configs", { get: function () { if (this._config) return this._config; else { console.log("config配置文件还未读取!!"); return null; } }, set: function (res) { console.log("解析配置文件"); if (!res) return; for (var i = 0; i < res.length; i++) { var arr = []; var json = res[i]["json"]; for (var j = 0; j < json.length; j++) { arr.push(json[j]); } this._config[res[i].name] = arr; } }, enumerable: false, configurable: true }); /** 导入配置文件 */ ConfigDataMgr.prototype.loadConfigs = function (cb) { console.log("读取配置文件"); this._config = {}; var url = "configs"; var self = this; cc.loader.loadResDir(url, cc.Asset, function (err, res) { self.configs = res; console.log("配置文件解析完成"); console.log(self.attrs); App_1.App.DataManager.init(); cb(); }); }; /** 随机生成昵称 */ ConfigDataMgr.prototype.getNick = function () { var range = this.nicks.length; return this.nicks[NumberUtil_1.NumberUtil.getRandomInt(0, range)]; }; /** 获取消耗列表 */ ConfigDataMgr.prototype.getConsumeList = function () { return this.consumes; }; /** 获取任务列表 */ ConfigDataMgr.prototype.getTaskList = function () { return this.tasks; }; /** 获取福利Day列表 */ ConfigDataMgr.prototype.getFuLiDayList = function () { return this.fuli_days; }; /** 获取福利Watch列表 */ ConfigDataMgr.prototype.getFuLiWatchList = function () { return this.fuli_watchs; }; /** 获取指定狗的初始属性 */ ConfigDataMgr.prototype.getBeginingAttr = function (prop) { var result; for (var i = 0; i < this.attrs.length; i++) { var item = this.attrs[i]; if (item.prop == EnumDefine_1.EConfigAttrProp[prop]) { result = item; break; } } return result; }; /** 获取年龄段 */ ConfigDataMgr.prototype.getAgeGroup = function (level) { return level < 11 ? EnumDefine_1.EAgeGroup.PERIOD_KIDS : level < 31 ? EnumDefine_1.EAgeGroup.PERIOD_YOUNG : EnumDefine_1.EAgeGroup.PERIOD_GROWNUP; }; /** 获取指定狗的成长属性 */ ConfigDataMgr.prototype.getGrowingAttr = function (level) { var prop = level < 11 ? EnumDefine_1.EConfigAttrProp.cq_childhood : level < 31 ? EnumDefine_1.EConfigAttrProp.cq_youth : EnumDefine_1.EConfigAttrProp.cq_adulthood; var result; for (var i = 0; i < this.attrs.length; i++) { var item = this.attrs[i]; if (item.prop == EnumDefine_1.EConfigAttrProp[prop]) { result = item; break; } } return result; }; /** 通过亲密度等级获取升级所需经验 */ ConfigDataMgr.prototype.getExpByLv = function (lv) { for (var i = 0; i < this.exps.length; i++) { var item = this.exps[i]; if (item.lv == lv) { return item.exp; } } return -1; }; Object.defineProperty(ConfigDataMgr.prototype, "DOG_MAX_LEVEL", { /** 获取狗的最高等级 */ get: function () { return this.exps.length; }, enumerable: false, configurable: true }); /** 获取每日签到奖励 */ ConfigDataMgr.prototype.getFuLiDayReward = function (day) { for (var i = 0; i < this.fuli_days.length; i++) { if (this.fuli_days[i].day == day) return this.fuli_days[i].reward; } console.log("出错了"); }; return ConfigDataMgr; }(Singleton_1.Singleton)); exports.ConfigDataMgr = ConfigDataMgr; cc._RF.pop();