WidgetItem.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 : UIComponent
  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. btnClick.onClick.AddListener(OnclickItem);
  26. }
  27. private Action onClickItem;
  28. private async void OnclickItem()
  29. {
  30. if (onClickItem != null)
  31. {
  32. onClickItem.Invoke();
  33. return;
  34. }
  35. if (itemInfo == null)
  36. {
  37. return;
  38. }
  39. // ItemPanel itemPanel = await UIManager.Instance.LoadAndOpenPanel<ItemPanel>(null, layer: UILayer.Top);
  40. // itemPanel.InitItemPanel(itemInfo);
  41. }
  42. public void InitWidget(ItemInfo itemInfo, Action onClickItem = null)
  43. {
  44. this.itemInfo = itemInfo;
  45. this.onClickItem = onClickItem;
  46. border.gameObject.SetActive(false);
  47. light.gameObject.SetActive(false);
  48. icon.gameObject.SetActive(true);
  49. icon.icon_name = itemInfo.config.icon;
  50. if (itemInfo.count.Value > 0)
  51. {
  52. Text_Count.gameObject.SetActive(true);
  53. Text_Count.text = itemInfo.count.Value.ToStringEx();
  54. }
  55. else
  56. {
  57. Text_Count.gameObject.SetActive(false);
  58. }
  59. }
  60. }
  61. }