ItemPanel.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using Core.Language;
  2. using GameLogic.Bag;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using Utility;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "ItemPanel")]
  10. public partial class ItemPanel : UIPanel
  11. {
  12. private void Init()
  13. {
  14. }
  15. protected override void AddEvent()
  16. {
  17. }
  18. protected override void DelEvent()
  19. {
  20. }
  21. public override void AddButtonEvent()
  22. {
  23. btnBack.onClick.AddListener(OnclickClose);
  24. btnDi.onClick.AddListener(OnclickClose2);
  25. }
  26. private void OnclickClose2()
  27. {
  28. OnclickClose();
  29. }
  30. private void OnclickClose()
  31. {
  32. UIManager.Instance.HideUIUIPanel(this);
  33. eqItem.own.SetActive(false);
  34. //UIManager.Instance.DormancyGComponent(eqItem);
  35. }
  36. private WidgetItem eqItem;
  37. public async void InitItemPanel(ItemInfo itemInfo)
  38. {
  39. foreach (GameObject gameObject in attIcon)
  40. {
  41. gameObject.transform.parent.gameObject.SetActive(false);
  42. }
  43. //
  44. // foreach (GameObject gameObject in attValue)
  45. // {
  46. // gameObject.SetActive(false);
  47. // }
  48. eqItem = await UIManager.Instance.CreateGComponentForObject<WidgetItem>(item, null,
  49. root: itemRoot);
  50. eqItem.InitWidget(itemInfo);
  51. if (itemInfo.eqInfo != null)
  52. {
  53. txtlName.text = LanguageManager.Instance.Text(itemInfo.eqInfo.basicEquipConfig.eqName);
  54. zyIcon.icon_name = HeroUITools.GetZyIcon(itemInfo.eqInfo.basicEquipConfig.profession);
  55. desc.text = LanguageManager.Instance.Text(itemInfo.eqInfo.basicEquipConfig.desc);
  56. for (int i = 0; i < itemInfo.eqInfo.basicEquipConfig.AttType.Length; i++)
  57. {
  58. int attType = itemInfo.eqInfo.basicEquipConfig.AttType[i];
  59. int attValue = itemInfo.eqInfo.basicEquipConfig.AttValue[i];
  60. SetAttUI(attType, attValue, i);
  61. }
  62. }
  63. else
  64. {
  65. txtlName.text = LanguageManager.Instance.Text(itemInfo.config.itemName);
  66. desc.text = LanguageManager.Instance.Text(itemInfo.config.itemDesc);
  67. }
  68. }
  69. private void SetAttUI(int type, int value, int idx)
  70. {
  71. GameObject iconGo = attIcon[idx] as GameObject;
  72. GameObject attGo = attValue[idx] as GameObject;
  73. iconGo.transform.parent.gameObject.SetActive(true);
  74. attGo.GetComponent<TextMeshProUGUI>().text = value.ToStringEx();
  75. if (type == 1)
  76. {
  77. iconGo.GetComponent<MyImage>().icon_name = "icon_at_hp";
  78. }
  79. else if (type == 2)
  80. {
  81. iconGo.GetComponent<MyImage>().icon_name = "icon_att_Sword02";
  82. }
  83. else if (type == 3)
  84. {
  85. iconGo.GetComponent<MyImage>().icon_name = "icon_att_Shield";
  86. }
  87. }
  88. }
  89. }