123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { Framework } from "../../framework/Framework";
- import { BaseItem, ItemEnum } from "../common/InterfaceAddEnum";
- import { MaterialConf } from "../config/MaterialConf";
- import { GameEvent } from "./GameEvent";
- class Data {
- private _goodsData: { [id: string]: BaseItem } = {};
- init(): void {
- this.reset();
- }
- reset(): void {
- this._goodsData = {};
- }
- purge(): void {
- this.reset();
- }
- setAllGoods(data) {
- this._goodsData = {};
- let conf = MaterialConf.data;
- for (const key in data) {
- if (Object.prototype.hasOwnProperty.call(data, key)) {
- const element = data[key];
- let mConf = conf[key];
- if (mConf) {
- let item = {
- id: key,
- count: Number(element),
- type: ItemEnum.material,
- conf: mConf,
- }
- this._goodsData[key] = item;
- }
- }
- }
- }
- getAllGoods() {
- return this._goodsData;
- }
- }
- export let GoodsData = new Data;
|