ConfigData.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { _decorator, Component, CCString, JsonAsset } from 'cc';
  2. import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('ConfigData')
  5. export class ConfigData extends Component {
  6. @property({ type: [CCString], tooltip: "需要加载的配置文件" }) configNames = [];
  7. public static configMap: Map<string, any> = new Map();
  8. public async loadConfig() {
  9. for (let i = 0; i < this.configNames.length; i++) {
  10. let result = await (await ResourcesUtils.load<JsonAsset>("Configs/" + this.configNames[i], JsonAsset, this.node)).json;
  11. ConfigData.configMap.set(this.configNames[i], result);
  12. }
  13. }
  14. }
  15. // import { _decorator, Component, JsonAsset } from "cc";
  16. // import { ResourcesUtils } from "../core/resourceManager/ResourcesUtils";
  17. // const { ccclass, property } = _decorator;
  18. // /**
  19. // * 配置数据
  20. // *
  21. // */
  22. // @ccclass('ConfigData')
  23. // export class ConfigData extends Component {
  24. // /**一方最大参战人数*/
  25. // public battleMaxNum: number = 50;
  26. // /**系统配置 */
  27. // public systemConfig;
  28. // /**神将基础配置 */
  29. // public generalConfig;
  30. // /**抽奖配置配置 */
  31. // public lotteryConfig;
  32. // /**等级解锁配置 */
  33. // public generalUnlockConfig;
  34. // /**飞行宝箱配置 */
  35. // public flyBoxConfig;
  36. // public setBaseData() {
  37. // this.setSystemConfig();
  38. // this.setBaseGeneralData();
  39. // this.setLotteryData();
  40. // this.setFlyBoxConfig();
  41. // }
  42. // private async setSystemConfig() {
  43. // this.systemConfig = await (await ResourcesUtils.load<JsonAsset>("Configs/systemConfig", JsonAsset, this.node)).json;
  44. // } F
  45. // private async setBaseGeneralData() {
  46. // this.generalConfig = await (await ResourcesUtils.load<JsonAsset>("Configs/generalBase", JsonAsset, this.node)).json;
  47. // }
  48. // private async setLotteryData() {
  49. // this.lotteryConfig = await (await ResourcesUtils.load<JsonAsset>("Configs/turntable", JsonAsset, this.node)).json;
  50. // }
  51. // private async setFlyBoxConfig() {
  52. // this.flyBoxConfig = await (await ResourcesUtils.load<JsonAsset>("Configs/flyBox", JsonAsset, this.node)).json;
  53. // }
  54. // }