WidgetItem.cs 2.1 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.gameObject.SetActive(true);
  51. icon.icon_name = itemInfo.config.icon;
  52. Icon_WenHao.gameObject.SetActive(false);
  53. if (itemInfo.count.Value > 0)
  54. {
  55. Text_Count.gameObject.SetActive(true);
  56. Text_Count.text = itemInfo.count.Value.ToStringEx();
  57. }
  58. else
  59. {
  60. Text_Count.gameObject.SetActive(false);
  61. }
  62. }
  63. public void ShowWenhao()
  64. {
  65. isClick = false;
  66. Icon_WenHao.gameObject.SetActive(true);
  67. icon.gameObject.SetActive(false);
  68. Text_Count.gameObject.SetActive(false);
  69. }
  70. public override void DormancyObj()
  71. {
  72. transform.RecoverColor();
  73. base.DormancyObj();
  74. }
  75. }
  76. }