ProfessionEquipmentPanel.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections.Generic;
  2. using Fort23.UTool;
  3. using GameLogic.Bag;
  4. using UnityEngine;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "ProfessionEquipmentPanel" )]
  8. public partial class ProfessionEquipmentPanel : UIPanel
  9. {
  10. private void Init()
  11. {
  12. }
  13. protected override void AddEvent()
  14. {
  15. }
  16. protected override void DelEvent()
  17. {
  18. }
  19. public override void AddButtonEvent()
  20. {
  21. btnBack.onClick.AddListener(OnclickBack);
  22. btnZs.onClick.AddListener(OnclickZS);
  23. btnFs.onClick.AddListener(OnclickFS);
  24. btnMs.onClick.AddListener(OnclickMS);
  25. btnYx.onClick.AddListener(OnclickYX);
  26. }
  27. private async void OnclickZS()
  28. {
  29. OpenSpecificProfessionEquipmentPanel(1);
  30. }
  31. private async void OnclickFS()
  32. {
  33. OpenSpecificProfessionEquipmentPanel(2);
  34. }
  35. private async void OnclickMS()
  36. {
  37. OpenSpecificProfessionEquipmentPanel(3);
  38. }
  39. private async void OnclickYX()
  40. {
  41. OpenSpecificProfessionEquipmentPanel(4);
  42. }
  43. /// <summary>
  44. /// 打开对应职业的装备面板
  45. /// </summary>
  46. /// <param name="zy">1战士;2法师;3牧师;4游侠</param>
  47. private async void OpenSpecificProfessionEquipmentPanel(int zy)
  48. {
  49. SpecificProfessionEquipmentPanel specificProfessionEquipmentPanel
  50. = await UIManager.Instance.LoadAndOpenPanel<SpecificProfessionEquipmentPanel>(null);
  51. specificProfessionEquipmentPanel.InitPanel(zy);
  52. }
  53. private void OnclickBack()
  54. {
  55. UIManager.Instance.HideUIUIPanel(this);
  56. }
  57. public async void InitPanel()
  58. {
  59. SetZyEqs(zsEqs, 1);
  60. SetZyEqs(fsEqs, 2);
  61. SetZyEqs(msEqs, 3);
  62. SetZyEqs(yxEqs, 4);
  63. }
  64. private async void SetZyEqs(List<object> eqs, int zy)
  65. {
  66. foreach (GameObject eqGo in eqs)
  67. {
  68. WidgetItem eqItem = await UIManager.Instance.
  69. CreateGComponentForObject<WidgetItem>(eqGo,
  70. null, root:eqGo.GetComponent<RectTransform>());
  71. LogTool.Log(eqGo + "设置");
  72. eqItem.SetEmpty();
  73. }
  74. if (BagController.Instance.EqDic.ContainsKey(zy))
  75. {
  76. List<ItemInfo> eqList = BagController.Instance.EqDic[zy];
  77. foreach (ItemInfo eqInfo in eqList)
  78. {
  79. if (eqInfo.eqInfo.isEquip)
  80. {
  81. // if(eqInfo.eqInfo.basicEquipConfig.Type)
  82. GameObject eqGo = eqs[eqInfo.eqInfo.basicEquipConfig.Type - 1] as GameObject;
  83. WidgetItem eqItem = await UIManager.Instance.
  84. CreateGComponentForObject<WidgetItem>(eqGo, null, root:eqGo.GetComponent<RectTransform>());
  85. eqItem.InitWidget(eqInfo);
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }