itemDtManager.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { AssetsHelper } from "../framework/asset/AssetsHelper";
  2. import JsonManager from "../framework/json/JsonManager";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. class itemDtManager {
  6. /**
  7. *
  8. * @param itemID 物品ID
  9. * @returns 当前物品数据列表
  10. */
  11. public getDataByID(itemID: number) {
  12. let data = JsonManager.getInstance().GetDataByName(AssetsHelper.ITEM_DATA_JSON);
  13. let itemDt = data[itemID];
  14. if (itemDt) {
  15. return itemDt;
  16. }
  17. }
  18. /**
  19. *
  20. * @param itemID 物品ID
  21. * @returns 当前物品的类型
  22. */
  23. public getItemType(itemID: number) {
  24. let type = this.getDataByID(itemID).type;
  25. if (type) return type;
  26. }
  27. /**
  28. *
  29. * @param itemID 物品ID
  30. * @returns 当前物品的属性值 (具体是什么类型的值 根据物品类型判断)
  31. */
  32. public getItemValue(itemID: number) {
  33. let value = this.getDataByID(itemID).value;
  34. if (value) return value;
  35. }
  36. /**
  37. *
  38. * @param itemID 物品ID
  39. * @returns 当前物品的动画索引
  40. */
  41. public getItemName(itemID: number) {
  42. let animIdx = this.getDataByID(itemID).anmiName;
  43. if (animIdx) return animIdx;
  44. }
  45. /**
  46. *
  47. * @param itemID 物品ID
  48. * @returns 当前物品的图片名称
  49. */
  50. public getItemResName(itemID: number) {
  51. let resName = this.getDataByID(itemID).resPath;
  52. if (resName) return resName;
  53. }
  54. }
  55. export default new itemDtManager()