SpecificProfessionEquipmentPanel.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatEvent;
  4. using Core.Language;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using GameLogic.Bag;
  8. using UnityEngine;
  9. namespace Fort23.Mono
  10. {
  11. [UIBinding(prefab = "SpecificProfessionEquipmentPanel" )]
  12. public partial class SpecificProfessionEquipmentPanel : UIPanel
  13. {
  14. private void Init()
  15. {
  16. }
  17. protected override void AddEvent()
  18. {
  19. }
  20. protected override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. btnBack.onClick.AddListener(OnclickClose);
  26. btnOnce.onClick.AddListener(OnclickOnce);
  27. btnZs.onClick.AddListener(OnclickZS);
  28. btnFs.onClick.AddListener(OnclickFS);
  29. btnMs.onClick.AddListener(OnclickMS);
  30. btnYx.onClick.AddListener(OnclickYX);
  31. }
  32. private void OnclickZS()
  33. {
  34. if (curZy == 1)
  35. {
  36. return;
  37. }
  38. // HighLight(curZy);
  39. HeroUITools.OpenSpecificProfessionEquipmentPanel(1);
  40. }
  41. private void OnclickFS()
  42. {
  43. if (curZy == 2)
  44. {
  45. return;
  46. }
  47. // HighLight(curZy);
  48. HeroUITools.OpenSpecificProfessionEquipmentPanel(2);
  49. }
  50. private void OnclickMS()
  51. {
  52. if (curZy == 3)
  53. {
  54. return;
  55. }
  56. // HighLight(curZy);
  57. HeroUITools.OpenSpecificProfessionEquipmentPanel(3);
  58. }
  59. private void OnclickYX()
  60. {
  61. if (curZy == 4)
  62. {
  63. return;
  64. }
  65. // HighLight(curZy);
  66. HeroUITools.OpenSpecificProfessionEquipmentPanel(4);
  67. }
  68. private bool isClickOnce = false;
  69. public int curZy;
  70. //流光溢彩 别出心裁 千篇一律 呕心沥血
  71. private void OnclickOnce()
  72. {
  73. isClickOnce = PlayerManager.Instance.eqController.QuickEquip(curZy);
  74. if (isClickOnce)
  75. {
  76. SendWearEvent();
  77. UIManager.Instance.DormancyAllGComponent<WidgetItem>(poolName : SpecificEqsPoolName);
  78. HeroUITools.UpdateZyEqIcon(curZy, eqs, poolName : SpecificEqsPoolName);
  79. // altertRed.SetActive(false);
  80. SetRedPoints(true);
  81. }
  82. }
  83. private void HighLight(int zy)
  84. {
  85. for (int i = 0; i < highLights.Count; i++)
  86. {
  87. GameObject obj = highLights[i] as GameObject;
  88. if (zy > 0 && zy == i + 1)
  89. {
  90. obj.SetActive(true);
  91. }
  92. else
  93. {
  94. obj.SetActive(false);
  95. }
  96. }
  97. }
  98. private void SendWearEvent()
  99. {
  100. // ProfessionEquipmentPanel professionEquipmentPanel = UIManager.Instance.GetComponent<ProfessionEquipmentPanel>();
  101. //
  102. // professionEquipmentPanel.UpdateAllEq();
  103. HeroEquipEventData data = new HeroEquipEventData();
  104. data.zy = curZy;
  105. // EventManager.Instance.Dispatch(CustomEventType.HeroPowerUp, data);
  106. EventManager.Instance.Dispatch(CustomEventType.HeroEquip, data);
  107. }
  108. private async void OnclickClose()
  109. {
  110. UIManager.Instance.HideUIUIPanel(this);
  111. closeAction?.Invoke();
  112. UIManager.Instance.DormancyAllGComponent<WidgetItem>(SpecificEqsPoolName);
  113. if (isClickOnce)
  114. {
  115. // UIManager.Instance.DormancyAllGComponent<WidgetItem>("eq");
  116. }
  117. }
  118. private string SpecificEqsPoolName = "eq2";
  119. private Action closeAction;
  120. public void InitPanel(int zy, Action action = null)
  121. {
  122. isClickOnce = false;
  123. curZy = zy;
  124. closeAction = action;
  125. HighLight(curZy);
  126. SetZyInfo();
  127. UIManager.Instance.DormancyAllGComponent<WidgetItem>(SpecificEqsPoolName);
  128. HeroUITools.UpdateZyEqIcon(zy, eqs, poolName : SpecificEqsPoolName);
  129. SetRedPoints();
  130. }
  131. private void SetRedPoints(bool reCal = false)
  132. {
  133. for (int i = 1; i <= 4; i++)
  134. {
  135. GameObject obj = zyRedPoints[i - 1] as GameObject;
  136. if (PlayerManager.Instance.eqController.IsBetterEqs4OneZy(i, reCal))
  137. {
  138. obj.SetActive(true);
  139. }
  140. else
  141. {
  142. obj.SetActive(false);
  143. }
  144. }
  145. if (PlayerManager.Instance.eqController.IsBetterEqs4OneZy(curZy))
  146. {
  147. altertRed.SetActive(true);
  148. }
  149. else
  150. {
  151. altertRed.SetActive(false);
  152. }
  153. }
  154. private void SetZyInfo()
  155. {
  156. switch (curZy)
  157. { //
  158. case 1:
  159. SetZyTxt(97);
  160. zyBg.icon_name = "bg_warrior";
  161. colorBg.color = new Color(255, 215, 0);
  162. break;
  163. case 2:
  164. SetZyTxt(98);
  165. zyBg.icon_name = "bg_priest";
  166. colorBg.color = new Color(128, 0, 128);
  167. break;
  168. case 3:
  169. SetZyTxt(99);
  170. zyBg.icon_name = "bg_Mage";
  171. colorBg.color = new Color(255, 255, 204);
  172. break;
  173. case 4:
  174. SetZyTxt(100);
  175. zyBg.icon_name = "bg_Archer";
  176. colorBg.color = new Color(0, 128, 0);
  177. break;
  178. default:
  179. break;
  180. }
  181. }
  182. private void SetZyTxt(int languageId)
  183. {
  184. zyTitle.text = LanguageManager.Instance.Text(languageId);
  185. miniTitle.text = LanguageManager.Instance.Text(languageId);
  186. }
  187. private void SetZyBg(int zy)
  188. {
  189. }
  190. }
  191. }