WidgetItem.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using Core.Language;
  3. using Fort23.UTool;
  4. using GameLogic.Bag;
  5. using GameLogic.Equipment;
  6. using UnityEngine;
  7. using Utility;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "WidgetItem")]
  11. public partial class WidgetItem : ItemWidgetBasic
  12. {
  13. public ItemInfo itemInfo;
  14. private void Init()
  15. {
  16. }
  17. public override void AddEvent()
  18. {
  19. }
  20. public override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. Btn_WidgetItem.onClick.AddListener(() => { ItemDetailsPanel.OpenPanel(itemInfo); });
  26. base.AddButtonEvent();
  27. }
  28. public void InitWidget(ItemInfo itemInfo)
  29. {
  30. this.itemInfo = itemInfo;
  31. icon.gameObject.SetActive(true);
  32. icon.icon_name = itemInfo.config.icon;
  33. Icon_WenHao.gameObject.SetActive(false);
  34. if (itemInfo.count.Value > 0)
  35. {
  36. Text_Count.gameObject.SetActive(true);
  37. Text_Count.text = itemInfo.count.Value.ToStringEx();
  38. }
  39. else
  40. {
  41. Text_Count.gameObject.SetActive(false);
  42. }
  43. }
  44. public void ShowWenhao()
  45. {
  46. Icon_WenHao.gameObject.SetActive(true);
  47. icon.gameObject.SetActive(false);
  48. Text_Count.gameObject.SetActive(false);
  49. }
  50. public override void DormancyObj()
  51. {
  52. transform.RecoverColor();
  53. base.DormancyObj();
  54. }
  55. }
  56. }