AppBarPanel.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Bag;
  7. using GameLogic.Combat;
  8. using GameLogic.Combat.CombatTool;
  9. namespace Fort23.Mono
  10. {
  11. [UIBinding(prefab = "AppBarPanel")]
  12. public partial class AppBarPanel : UIPanel
  13. {
  14. public UIPanel currentOpenUIPanel;
  15. int useCount = 0;
  16. private void Init()
  17. {
  18. isAddStack = false;
  19. }
  20. protected override void AddEvent()
  21. {
  22. EventManager.Instance.AddEventListener(CustomEventType.DivineSensePointChange, DivineSensePointChange);
  23. }
  24. protected override void DelEvent()
  25. {
  26. EventManager.Instance.RemoveEventListener(CustomEventType.DivineSensePointChange, DivineSensePointChange);
  27. }
  28. private void DivineSensePointChange(IEventData e)
  29. {
  30. Text_divineSensePoint.text =
  31. $"{AccountFileInfo.Instance.playerData.divineSensePoint}/{PlayerManager.Instance.gameConstantConfig.DetectEventCount}";
  32. }
  33. public override void AddButtonEvent()
  34. {
  35. Btn_Shop.onClick.AddListener(async () => { Btn_Shop_Click(); });
  36. bnt_shengShi.onClick.AddListener(() => { DivineSenceInfoPanel.OpenPanel((count, useItems) => { Bnt_shengShi_onClick(count, useItems); }); });
  37. Btn_GongFa.onClick.AddListener(async () => { Btn_GongFa_Click(); });
  38. Btn_HeroInfomation.onClick.AddListener(async () => { Btn_HeroInfomation_Click(); });
  39. Btn_DongFu.onClick.AddListener(async () => { Bne_dongfu_Click(); });
  40. Btn_Back.onClick.AddListener(() =>
  41. {
  42. UIManager.Instance.HideUIUIPanel(currentOpenUIPanel);
  43. // currentOpenUIPanel = null;
  44. });
  45. }
  46. public async void Btn_Shop_Click()
  47. {
  48. if (currentOpenUIPanel is ShopPanel)
  49. {
  50. return;
  51. }
  52. UIPanel uiPanel = currentOpenUIPanel;
  53. CombatDrive.Instance.CombatController.isUpdate = false;
  54. ShopPanel shopPanel = await ShopPanel.OpenPanel();
  55. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel || uiPanel is MainHeroPanel)
  56. {
  57. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  58. }
  59. if (!shopPanel.IsClose)
  60. await shopPanel.UIClosed();
  61. CombatDrive.Instance.CombatController.isUpdate = true;
  62. }
  63. public async void Btn_GongFa_Click()
  64. {
  65. if (currentOpenUIPanel is SkillSelectPanel)
  66. {
  67. return;
  68. }
  69. UIPanel uiPanel = currentOpenUIPanel;
  70. SkillSelectPanel skillSelectPanel = await SkillSelectPanel.OpenSkillSelectPanel();
  71. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel || uiPanel is MainHeroPanel)
  72. {
  73. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  74. }
  75. }
  76. public async void Btn_HeroInfomation_Click()
  77. {
  78. if (currentOpenUIPanel is MainHeroPanel)
  79. {
  80. return;
  81. }
  82. UIPanel uiPanel = currentOpenUIPanel;
  83. MainHeroPanel mainHeroPanel = await MainHeroPanel.OpenPanel();
  84. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel || uiPanel is MainHeroPanel)
  85. {
  86. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  87. }
  88. if (!mainHeroPanel.IsClose)
  89. await mainHeroPanel.UIClosed();
  90. }
  91. public async void Bne_dongfu_Click()
  92. {
  93. if (currentOpenUIPanel is CaveMainPanel)
  94. {
  95. return;
  96. }
  97. UIPanel uiPanel = currentOpenUIPanel;
  98. CombatDrive.Instance.CombatController.isUpdate = false;
  99. CaveMainPanel heroInformationPanel = await CaveMainPanel.OpenPanel();
  100. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel || uiPanel is MainHeroPanel)
  101. {
  102. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  103. }
  104. if (!heroInformationPanel.IsClose)
  105. await heroInformationPanel.UIClosed();
  106. CombatDrive.Instance.CombatController.isUpdate = true;
  107. }
  108. private async CTask OpenSelectSkillPanel()
  109. {
  110. }
  111. private async void Bnt_shengShi_onClick(int count, List<ItemInfo> useItems)
  112. {
  113. if (AccountFileInfo.Instance.playerData.divineSensePoint <
  114. PlayerManager.Instance.gameConstantConfig.DetectEventCount)
  115. {
  116. TipMessagePanel.OpenTipMessagePanel("神识值不够!");
  117. return;
  118. }
  119. EventSystemManager.Instance.CancelEvent();
  120. if (EventSystemManager.Instance.isTriggerEvent)
  121. return;
  122. EventSystemManager.Instance.isTriggerEvent = true;
  123. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  124. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  125. .playerHeroEntity.GameObject.transform);
  126. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  127. await TimerComponent.Instance.WaitAsync(800);
  128. EventSystemManager.Instance.isTriggerEvent = false;
  129. if (eventLists == null || eventLists.Count == 0)
  130. {
  131. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  132. return;
  133. }
  134. if (eventLists != null && eventLists.Count > 0)
  135. {
  136. await DivineSenceEventPreviewPanel.OpenPanel();
  137. }
  138. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  139. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  140. }
  141. public void CustomInit(UIPanel uiPanel)
  142. {
  143. if (uiPanel is MainPanel)
  144. {
  145. Btn_Back.gameObject.SetActive(false);
  146. bnt_shengShi.gameObject.SetActive(true);
  147. BtnRoot.gameObject.SetActive(true);
  148. currentOpenUIPanel = uiPanel;
  149. }
  150. else if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel || uiPanel is MainHeroPanel)
  151. {
  152. Btn_Back.gameObject.SetActive(true);
  153. bnt_shengShi.gameObject.SetActive(false);
  154. BtnRoot.gameObject.SetActive(true);
  155. currentOpenUIPanel = uiPanel;
  156. }
  157. else
  158. {
  159. BtnRoot.gameObject.SetActive(false);
  160. Btn_Back.gameObject.SetActive(true);
  161. bnt_shengShi.gameObject.SetActive(false);
  162. currentOpenUIPanel = uiPanel;
  163. }
  164. if (uiPanel is CaveMainPanel)
  165. {
  166. Toggle_BtnRoot.ShowTargetIndex(2);
  167. }
  168. else if (uiPanel is SkillSelectPanel)
  169. {
  170. Toggle_BtnRoot.ShowTargetIndex(1);
  171. }
  172. else if (uiPanel is ShopPanel)
  173. {
  174. Toggle_BtnRoot.ShowTargetIndex(3);
  175. }
  176. else if (uiPanel is MainHeroPanel)
  177. {
  178. Toggle_BtnRoot.ShowTargetIndex(0);
  179. }
  180. else
  181. {
  182. Toggle_BtnRoot.Hide();
  183. }
  184. }
  185. public async static CTask OpenPanel(UIPanel uiPanel)
  186. {
  187. AppBarPanel appBarPanel = null;
  188. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  189. {
  190. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  191. }
  192. else
  193. {
  194. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  195. await appBarPanel.Show();
  196. }
  197. appBarPanel.CustomInit(uiPanel);
  198. }
  199. public async static CTask ClosePanel()
  200. {
  201. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  202. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  203. }
  204. }
  205. }