AppBarPanel.cs 10 KB

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