AppBarPanel.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. private BackgroundCom _backgroundCom;
  21. protected override void AddEvent()
  22. {
  23. EventManager.Instance.AddEventListener(CustomEventType.DivineSensePointChange, DivineSensePointChange);
  24. }
  25. protected override void DelEvent()
  26. {
  27. EventManager.Instance.RemoveEventListener(CustomEventType.DivineSensePointChange, DivineSensePointChange);
  28. }
  29. private void DivineSensePointChange(IEventData e)
  30. {
  31. Text_divineSensePoint.text =
  32. $"{AccountFileInfo.Instance.playerData.divineSensePoint}/{PlayerManager.Instance.gameConstantConfig.DetectEventCount}";
  33. }
  34. public override void AddButtonEvent()
  35. {
  36. Btn_Shop.onClick.AddListener(async () => { Btn_Shop_Click(); });
  37. bnt_shengShi.onClick.AddListener(() => { Bnt_ShengShi_Click(); });
  38. Btn_GongFa.onClick.AddListener(async () => { Btn_GongFa_Click(); });
  39. Btn_HeroInfomation.onClick.AddListener(async () => { Btn_HeroInfomation_Click(); });
  40. Btn_DongFu.onClick.AddListener(async () => { Bne_dongfu_Click(); });
  41. Btn_Back.onClick.AddListener(() =>
  42. {
  43. UIManager.Instance.HideUIUIPanel(currentOpenUIPanel);
  44. // currentOpenUIPanel = null;
  45. });
  46. Btn_Menu.onClick.AddListener(async () =>
  47. {
  48. _backgroundCom = await UIManager.Instance.CreateGComponent<BackgroundCom>(null, root: MenuBgRoot);
  49. MenuRoot.SetActive(true);
  50. });
  51. Btn_Back1.onClick.AddListener(() => { CloseMenu(); });
  52. Btn_DaoYou.onClick.AddListener(() =>
  53. {
  54. DaoYouPanel.OpenPanel();
  55. CloseMenu();
  56. });
  57. Btn_Tower.onClick.AddListener(() =>
  58. {
  59. TowerPanel.OpenPanel(1);
  60. CloseMenu();
  61. });
  62. }
  63. private void CloseMenu()
  64. {
  65. UIManager.Instance.DormancyGComponent(_backgroundCom);
  66. _backgroundCom = null;
  67. MenuRoot.SetActive(false);
  68. }
  69. public async void Bnt_ShengShi_Click()
  70. {
  71. await DivineSenceInfoPanel.OpenPanel((count, useItems) => { Bnt_shengShi_onClick(count, useItems); });
  72. }
  73. public async void Btn_Shop_Click()
  74. {
  75. if (currentOpenUIPanel is ShopPanel)
  76. {
  77. return;
  78. }
  79. UIPanel uiPanel = currentOpenUIPanel;
  80. CombatDrive.Instance.CombatController.isUpdate = false;
  81. ShopPanel shopPanel = await ShopPanel.OpenPanel();
  82. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  83. uiPanel is MainHeroPanel)
  84. {
  85. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  86. }
  87. if (!shopPanel.IsClose)
  88. await shopPanel.UIClosed();
  89. CombatDrive.Instance.CombatController.isUpdate = true;
  90. }
  91. public async void Btn_GongFa_Click()
  92. {
  93. if (currentOpenUIPanel is SkillSelectPanel)
  94. {
  95. return;
  96. }
  97. UIPanel uiPanel = currentOpenUIPanel;
  98. SkillSelectPanel skillSelectPanel = await SkillSelectPanel.OpenSkillSelectPanel();
  99. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  100. uiPanel is MainHeroPanel)
  101. {
  102. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  103. }
  104. }
  105. public async void Btn_HeroInfomation_Click()
  106. {
  107. if (currentOpenUIPanel is MainHeroPanel)
  108. {
  109. return;
  110. }
  111. UIPanel uiPanel = currentOpenUIPanel;
  112. MainHeroPanel mainHeroPanel = await MainHeroPanel.OpenPanel();
  113. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  114. uiPanel is MainHeroPanel)
  115. {
  116. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  117. }
  118. if (!mainHeroPanel.IsClose)
  119. await mainHeroPanel.UIClosed();
  120. }
  121. public async void Bne_dongfu_Click()
  122. {
  123. if (currentOpenUIPanel is CaveMainPanel)
  124. {
  125. return;
  126. }
  127. UIPanel uiPanel = currentOpenUIPanel;
  128. CombatDrive.Instance.CombatController.isUpdate = false;
  129. CaveMainPanel heroInformationPanel = await CaveMainPanel.OpenPanel();
  130. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  131. uiPanel is MainHeroPanel)
  132. {
  133. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  134. }
  135. if (!heroInformationPanel.IsClose)
  136. await heroInformationPanel.UIClosed();
  137. CombatDrive.Instance.CombatController.isUpdate = true;
  138. }
  139. private async CTask OpenSelectSkillPanel()
  140. {
  141. }
  142. private async void Bnt_shengShi_onClick(int count, List<ItemInfo> useItems)
  143. {
  144. if (AccountFileInfo.Instance.playerData.divineSensePoint <
  145. PlayerManager.Instance.gameConstantConfig.DetectEventCount)
  146. {
  147. TipMessagePanel.OpenTipMessagePanel("神识值不够!");
  148. return;
  149. }
  150. EventSystemManager.Instance.CancelEvent();
  151. if (EventSystemManager.Instance.isTriggerEvent)
  152. return;
  153. if(PlayerGuideManager.Instance.curPhase == 2)
  154. PlayerGuideManager.Instance.StepInit();
  155. EventSystemManager.Instance.isTriggerEvent = true;
  156. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  157. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  158. .playerHeroEntity.GameObject.transform);
  159. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  160. await TimerComponent.Instance.WaitAsync(1200);
  161. EventSystemManager.Instance.isTriggerEvent = false;
  162. if (eventLists == null || eventLists.Count == 0)
  163. {
  164. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  165. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  166. // {
  167. // PlayerGuideManager.Instance.NextGuide();
  168. // }
  169. return;
  170. }
  171. if (eventLists != null && eventLists.Count > 0)
  172. {
  173. await DivineSenceEventPreviewPanel.OpenPanel();
  174. }
  175. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  176. // {
  177. // PlayerGuideManager.Instance.NextGuide();
  178. // }
  179. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  180. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  181. }
  182. public void CustomInit(UIPanel uiPanel)
  183. {
  184. if (uiPanel is MainPanel)
  185. {
  186. Btn_Back.gameObject.SetActive(false);
  187. bnt_shengShi.gameObject.SetActive(true);
  188. BtnRoot.gameObject.SetActive(true);
  189. currentOpenUIPanel = uiPanel;
  190. }
  191. else if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  192. uiPanel is MainHeroPanel)
  193. {
  194. Btn_Back.gameObject.SetActive(true);
  195. bnt_shengShi.gameObject.SetActive(false);
  196. BtnRoot.gameObject.SetActive(true);
  197. currentOpenUIPanel = uiPanel;
  198. }
  199. else
  200. {
  201. BtnRoot.gameObject.SetActive(false);
  202. Btn_Back.gameObject.SetActive(true);
  203. bnt_shengShi.gameObject.SetActive(false);
  204. currentOpenUIPanel = uiPanel;
  205. }
  206. if (uiPanel is CaveMainPanel)
  207. {
  208. Toggle_BtnRoot.ShowTargetIndex(2);
  209. }
  210. else if (uiPanel is SkillSelectPanel)
  211. {
  212. Toggle_BtnRoot.ShowTargetIndex(1);
  213. }
  214. else if (uiPanel is ShopPanel)
  215. {
  216. Toggle_BtnRoot.ShowTargetIndex(3);
  217. }
  218. else if (uiPanel is MainHeroPanel)
  219. {
  220. Toggle_BtnRoot.ShowTargetIndex(0);
  221. }
  222. else
  223. {
  224. Toggle_BtnRoot.Hide();
  225. }
  226. }
  227. public async static CTask OpenPanel(UIPanel uiPanel)
  228. {
  229. AppBarPanel appBarPanel = null;
  230. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  231. {
  232. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  233. }
  234. else
  235. {
  236. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  237. await appBarPanel.Show();
  238. }
  239. appBarPanel.CustomInit(uiPanel);
  240. }
  241. public async static CTask ClosePanel()
  242. {
  243. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  244. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  245. }
  246. }
  247. }