123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { IBenzAsset } from "../asset/IBenzAsset";
- import { BenzAssetManager } from "../asset/BenzAssetManager";
- import AccountModel from "../../data/Account/AccountModel";
- import { AssetsHelper } from "../asset/AssetsHelper";
- export default class JsonManager {
- static singleInstance: JsonManager = null;
- static getInstance(): JsonManager {
- if (JsonManager.singleInstance == null) {
- JsonManager.singleInstance = new JsonManager();
- }
- return JsonManager.singleInstance;
- }
- //所有json文件路径
- _josnPathList = [
- "json/buff",
- "json/Item",
- "json/Model",
- "json/npc",
- "json/airdrop_reward",
- "json/searchMarket_reward",
- "json/survivor_reward",
- "json/sign",
- ];
- _staticData = {}; //表格数据保存
- constructor() {
- }
- concatJosnPathList(assetList: IBenzAsset[]) {
- for (const key in this._josnPathList) {
- if (this._josnPathList.hasOwnProperty(key)) {
- const element = this._josnPathList[key];
- let asset =
- {
- fileName: element,
- type: cc.JsonAsset,
- isAutoRelease: false
- }
- assetList.push(asset);
- }
- }
- }
- /**
- * 提前加载静态数据
- */
- loadJsonData() {
- for (let index = 0; index < this._josnPathList.length; index++) {
- const element = this._josnPathList[index];
- let data: cc.JsonAsset = <cc.JsonAsset>BenzAssetManager.getInstance().getAsset(element);
- //cc.log("sdfa", JSON.stringify(data.json));
- this._staticData[element] = data.json;
- }
- this.dealWithSpecialData();
- }
- /**
- * 获得运用需要加载json路径列表
- */
- getJosnPathList() {
- return this._josnPathList;
- }
- /**
- * 加载资源完成之后 一些特殊处理
- */
- dealWithSpecialData() {
- //ToDo
- }
- /**
- * 根据表名获得数据
- * @param key
- */
- GetDataByName(key: string) {
- return this._staticData[key];
- }
- getSkinDtByID(curUseSKin: number) {
- let skinJson = this.GetDataByName(AssetsHelper.SKIN_JSON);
- let skinIdx = skinJson[curUseSKin];
- return skinIdx;
- }
- }
|