1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { AssetsHelper } from "../framework/asset/AssetsHelper";
- import JsonManager from "../framework/json/JsonManager";
- const { ccclass, property } = cc._decorator;
- @ccclass
- class itemDtManager {
- /**
- *
- * @param itemID 物品ID
- * @returns 当前物品数据列表
- */
- public getDataByID(itemID: number) {
- let data = JsonManager.getInstance().GetDataByName(AssetsHelper.ITEM_DATA_JSON);
- let itemDt = data[itemID];
- if (itemDt) {
- return itemDt;
- }
- }
- /**
- *
- * @param itemID 物品ID
- * @returns 当前物品的类型
- */
- public getItemType(itemID: number) {
- let type = this.getDataByID(itemID).type;
- if (type) return type;
- }
- /**
- *
- * @param itemID 物品ID
- * @returns 当前物品的属性值 (具体是什么类型的值 根据物品类型判断)
- */
- public getItemValue(itemID: number) {
- let value = this.getDataByID(itemID).value;
- if (value) return value;
- }
- /**
- *
- * @param itemID 物品ID
- * @returns 当前物品的动画索引
- */
- public getItemName(itemID: number) {
- let animIdx = this.getDataByID(itemID).anmiName;
- if (animIdx) return animIdx;
- }
- /**
- *
- * @param itemID 物品ID
- * @returns 当前物品的图片名称
- */
- public getItemResName(itemID: number) {
- let resName = this.getDataByID(itemID).resPath;
- if (resName) return resName;
- }
- }
- export default new itemDtManager()
|