WidgetItem.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using GameLogic.Bag;
  2. using Utility;
  3. namespace Fort23.Mono
  4. {
  5. [UIBinding(prefab = "WidgetItem")]
  6. public partial class WidgetItem : ItemWidgetBasic
  7. {
  8. public ItemInfo itemInfo;
  9. public bool isClick = false;
  10. private void Init()
  11. {
  12. }
  13. public override void AddEvent()
  14. {
  15. }
  16. public override void DelEvent()
  17. {
  18. }
  19. public override void AddButtonEvent()
  20. {
  21. Btn_WidgetItem.onClick.AddListener(() =>
  22. {
  23. if (!isClick)
  24. return;
  25. if (itemInfo.config.associateID == 3)
  26. {
  27. GongFaDetailsPanel.Open(itemInfo);
  28. }
  29. else if (itemInfo.config.associateID == 4)
  30. {
  31. FaBaoDetailsPanel.OpenPanel(itemInfo);
  32. }
  33. else
  34. {
  35. ItemDetailsPanel.OpenPanel(itemInfo);
  36. }
  37. });
  38. base.AddButtonEvent();
  39. }
  40. public void InitWidget(ItemInfo itemInfo, bool isclick = true)
  41. {
  42. this.isClick = isclick;
  43. this.itemInfo = itemInfo;
  44. Icon_quality.icon_name = "dec_wupin_pinzhi" + itemInfo.config.quality;
  45. icon.gameObject.SetActive(true);
  46. icon.icon_name = itemInfo.config.icon;
  47. Icon_WenHao.gameObject.SetActive(false);
  48. if (itemInfo.count.Value > 0)
  49. {
  50. Text_Count.gameObject.SetActive(true);
  51. Text_Count.text = itemInfo.count.Value.ToStringEx();
  52. }
  53. else
  54. {
  55. Text_Count.gameObject.SetActive(false);
  56. }
  57. }
  58. public void ShowWenhao()
  59. {
  60. isClick = false;
  61. Icon_WenHao.gameObject.SetActive(true);
  62. icon.gameObject.SetActive(false);
  63. Text_Count.gameObject.SetActive(false);
  64. }
  65. public override void DormancyObj()
  66. {
  67. transform.RecoverColor();
  68. base.DormancyObj();
  69. }
  70. }
  71. }