WidgetItem.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. private void Init()
  16. {
  17. }
  18. public override void AddEvent()
  19. {
  20. }
  21. public override void DelEvent()
  22. {
  23. }
  24. public override void AddButtonEvent()
  25. {
  26. Btn_WidgetItem.onClick.AddListener(() =>
  27. {
  28. if (itemInfo.config.associateID == 3)
  29. {
  30. GongFaDetailsPanel.Open(itemInfo);
  31. }
  32. else if (itemInfo.config.associateID == 4)
  33. {
  34. FaBaoDetailsPanel.OpenPanel(itemInfo);
  35. }
  36. else
  37. {
  38. ItemDetailsPanel.OpenPanel(itemInfo);
  39. }
  40. });
  41. base.AddButtonEvent();
  42. }
  43. public void InitWidget(ItemInfo itemInfo)
  44. {
  45. this.itemInfo = itemInfo;
  46. icon.gameObject.SetActive(true);
  47. icon.icon_name = itemInfo.config.icon;
  48. Icon_WenHao.gameObject.SetActive(false);
  49. if (itemInfo.count.Value > 0)
  50. {
  51. Text_Count.gameObject.SetActive(true);
  52. Text_Count.text = itemInfo.count.Value.ToStringEx();
  53. }
  54. else
  55. {
  56. Text_Count.gameObject.SetActive(false);
  57. }
  58. }
  59. public void ShowWenhao()
  60. {
  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. }