UIFallitem.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import auto_fallitem from "../../../ui/uidata/map/auto_fallitem";
  2. import UIBase from "../../../framework/ui/UIBase";
  3. import UIHelp from "../../../framework/ui/UIHelp";
  4. import { EVENT_TYPE, FALLITEM_TYPE } from "../../../gameLogic/utrl/gameEnum";
  5. import buffDtManager from "../../../dataManager/buffDtManager";
  6. import bundleManager from "../../../manager/bundleManager";
  7. import itemDtManager from "../../../dataManager/itemDtManager";
  8. import gameData from "../../../gameLogic/utrl/gameData";
  9. const { ccclass, menu, property } = cc._decorator;
  10. @ccclass
  11. @menu("UI/map/UIFallitem")
  12. export default class UIFallitem extends UIBase {
  13. ui: auto_fallitem = null;
  14. protected static prefabUrl = "map/fallitem";
  15. protected static className = "UIFallitem";
  16. private attr_value: number = 0; //属性值
  17. private attr_type: number = 0; //属性类型1食物,2药品,3子弹,4近战,5远程
  18. private inited = false;
  19. @property({ type: cc.Enum(FALLITEM_TYPE), displayName: '物资类型' })
  20. itemID = FALLITEM_TYPE.caidao;
  21. onUILoad() {
  22. this.ui = this.node.addComponent(auto_fallitem);
  23. }
  24. onStart() {
  25. this.initItem(this.itemID);
  26. }
  27. initItem(itemID: number) {
  28. this.itemID = itemID;
  29. let itemDt = itemDtManager.getDataByID(this.itemID);
  30. let ResName = itemDtManager.getItemResName(this.itemID);
  31. bundleManager.setBundleFrame('UI', ResName, this.node);
  32. this.attr_value = itemDt.value;
  33. this.attr_type = itemDt.type;
  34. this.inited = true;
  35. }
  36. /**
  37. *
  38. * @returns 物资属性值
  39. */
  40. getValue() {
  41. return this.attr_value;
  42. }
  43. /**
  44. *
  45. * @returns 物资类型
  46. * 1食物,2药品,3子弹,4近战,5远程
  47. */
  48. getType() {
  49. return this.attr_type;
  50. }
  51. /**获取id */
  52. getID() {
  53. return this.itemID;
  54. }
  55. onClose() {
  56. UIHelp.CloseUI(UIFallitem);
  57. }
  58. }