WidgetItem.cs 2.2 KB

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