WidgetItem.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. heroShards.SetActive(false);
  49. alertRed.SetActive(false);
  50. icon.gameObject.SetActive(true);
  51. if (itemInfo.count.Value > 0)
  52. {
  53. numObj.SetActive(true);
  54. num.text = itemInfo.count.Value.ToStringEx();
  55. }
  56. else
  57. {
  58. numObj.SetActive(false);
  59. }
  60. if (itemInfo.eqInfo != null)
  61. {
  62. // icon.icon_name = HeroUITools.GetEquipmentIconName(itemInfo);
  63. lvObj.SetActive(true);
  64. // txtLv.text = itemInfo.eqInfo.level + "级";
  65. txtLv.text = LanguageManager.Instance.Text(161, itemInfo.eqInfo.level);
  66. }
  67. // else if (itemInfo.config.itemTyp == 5)
  68. // {
  69. // heroShards.SetActive(true);
  70. // icon.gameObject.SetActive(false);
  71. // heroShardsIcon.icon_name = itemInfo.config.icon;
  72. // lvObj.SetActive(false);
  73. // }
  74. else
  75. {
  76. icon.icon_name = itemInfo.config.icon;
  77. lvObj.SetActive(false);
  78. }
  79. }
  80. }
  81. }