WidgetItem.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 =
  50. ConfigComponent.Instance.Get<SkillConfig>(itemInfo.config.associateVlaue[1] * 10 + 1);
  51. if (skillConfig.attribute == 1)
  52. {
  53. icon.icon_name = "dec_ck_gf_jin";
  54. }
  55. else if (skillConfig.attribute == 4)
  56. {
  57. icon.icon_name = "dec_ck_gf_mu";
  58. }
  59. else if (skillConfig.attribute == 2)
  60. {
  61. icon.icon_name = "dec_ck_gf_shui";
  62. }
  63. else if (skillConfig.attribute == 8)
  64. {
  65. icon.icon_name = "dec_ck_gf_huo";
  66. }
  67. else if (skillConfig.attribute == 16)
  68. {
  69. icon.icon_name = "dec_ck_gf_tu";
  70. }
  71. }
  72. //碎片
  73. else if (itemInfo.config.associateID == 11)
  74. {
  75. ItemConfig itemConfig2 = ConfigComponent.Instance.Get<ItemConfig>(itemInfo.config.associateVlaue[0]);
  76. SkillConfig skillConfig =
  77. ConfigComponent.Instance.Get<SkillConfig>(itemConfig2.associateVlaue[1] * 10 + 1);
  78. if (skillConfig.attribute == 1)
  79. {
  80. icon.icon_name = "dec_ck_gf_jin";
  81. }
  82. else if (skillConfig.attribute == 4)
  83. {
  84. icon.icon_name = "dec_ck_gf_mu";
  85. }
  86. else if (skillConfig.attribute == 2)
  87. {
  88. icon.icon_name = "dec_ck_gf_shui";
  89. }
  90. else if (skillConfig.attribute == 8)
  91. {
  92. icon.icon_name = "dec_ck_gf_huo";
  93. }
  94. else if (skillConfig.attribute == 16)
  95. {
  96. icon.icon_name = "dec_ck_gf_tu";
  97. }
  98. }
  99. else
  100. {
  101. icon.icon_name = itemInfo.config.icon;
  102. }
  103. icon.gameObject.SetActive(true);
  104. Icon_WenHao.gameObject.SetActive(false);
  105. if (itemInfo.count.Value > 0)
  106. {
  107. Text_Count.gameObject.SetActive(true);
  108. Text_Count.text = itemInfo.count.Value.ToStringEx();
  109. }
  110. else
  111. {
  112. Text_Count.gameObject.SetActive(false);
  113. }
  114. }
  115. public void ShowWenhao()
  116. {
  117. isClick = false;
  118. Icon_WenHao.gameObject.SetActive(true);
  119. icon.gameObject.SetActive(false);
  120. Text_Count.gameObject.SetActive(false);
  121. }
  122. public override void DormancyObj()
  123. {
  124. transform.RecoverColor();
  125. base.DormancyObj();
  126. }
  127. }
  128. }