WidgetItem.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Excel2Json;
  2. using Fort23.UTool;
  3. using GameLogic.Bag;
  4. using Utility;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "WidgetItem")]
  8. public partial class WidgetItem : ItemWidgetBasic
  9. {
  10. public ItemInfo itemInfo;
  11. public bool isClick = false;
  12. private void Init()
  13. {
  14. }
  15. public override void AddEvent()
  16. {
  17. }
  18. public override void DelEvent()
  19. {
  20. }
  21. public override void AddButtonEvent()
  22. {
  23. Btn_WidgetItem.onClick.AddListener(() =>
  24. {
  25. if (!isClick)
  26. return;
  27. if (itemInfo.config.associateID == 3)
  28. {
  29. GongFaDetailsPanel.Open(itemInfo);
  30. }
  31. else if (itemInfo.config.associateID == 4)
  32. {
  33. FaBaoDetailsPanel.OpenPanel(itemInfo);
  34. }
  35. else
  36. {
  37. ItemDetailsPanel.OpenPanel(itemInfo);
  38. }
  39. });
  40. base.AddButtonEvent();
  41. }
  42. public void InitWidget(ItemInfo itemInfo, bool isclick = true)
  43. {
  44. this.isClick = isclick;
  45. this.itemInfo = itemInfo;
  46. Icon_quality.icon_name = "dec_wupin_pinzhi" + itemInfo.config.quality;
  47. if (itemInfo.config.associateID == 3)
  48. {
  49. SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(itemInfo.config.associateVlaue[1]*10+1);
  50. if (skillConfig.attribute == 1)
  51. {
  52. icon.icon_name = "dec_ck_gf_jin";
  53. }
  54. else if (skillConfig.attribute == 4)
  55. {
  56. icon.icon_name = "dec_ck_gf_mu";
  57. }
  58. else if (skillConfig.attribute == 2)
  59. {
  60. icon.icon_name = "dec_ck_gf_shui";
  61. }
  62. else if (skillConfig.attribute == 8)
  63. {
  64. icon.icon_name = "dec_ck_gf_huo";
  65. }
  66. else if (skillConfig.attribute == 16)
  67. {
  68. icon.icon_name = "dec_ck_gf_tu";
  69. }
  70. }
  71. else
  72. {
  73. icon.icon_name = itemInfo.config.icon;
  74. }
  75. icon.gameObject.SetActive(true);
  76. Icon_WenHao.gameObject.SetActive(false);
  77. if (itemInfo.count.Value > 0)
  78. {
  79. Text_Count.gameObject.SetActive(true);
  80. Text_Count.text = itemInfo.count.Value.ToStringEx();
  81. }
  82. else
  83. {
  84. Text_Count.gameObject.SetActive(false);
  85. }
  86. }
  87. public void ShowWenhao()
  88. {
  89. isClick = false;
  90. Icon_WenHao.gameObject.SetActive(true);
  91. icon.gameObject.SetActive(false);
  92. Text_Count.gameObject.SetActive(false);
  93. }
  94. public override void DormancyObj()
  95. {
  96. transform.RecoverColor();
  97. base.DormancyObj();
  98. }
  99. }
  100. }