AppBarPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. $"{(int)AccountFileInfo.Instance.playerData.divineSensePoint}/{PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax}";
  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. CloseMenu();
  45. if (!(currentOpenUIPanel is MainPanel))
  46. UIManager.Instance.HideUIUIPanel(currentOpenUIPanel);
  47. else
  48. {
  49. UpdateUitoggleState();
  50. }
  51. AudioManager.Instance.PlayAudio("ui_fanhui.wav");
  52. // currentOpenUIPanel = null;
  53. });
  54. Btn_Menu.onClick.AddListener(async () =>
  55. {
  56. if (MenuRoot.activeSelf)
  57. return;
  58. _backgroundCom = await UIManager.Instance.CreateGComponent<BackgroundCom>(null, root: MenuBgRoot);
  59. Icon_Di.gameObject.SetActive(true);
  60. Btn_Back.gameObject.SetActive(true);
  61. bnt_shengShi.gameObject.SetActive(false);
  62. BtnRoot.gameObject.SetActive(true);
  63. MenuRoot.SetActive(true);
  64. Toggle_BtnRoot.ShowTargetIndex(4);
  65. });
  66. Btn_Back1.onClick.AddListener(() =>
  67. {
  68. CloseMenu();
  69. UpdateUitoggleState();
  70. });
  71. Btn_DaoYou.onClick.AddListener(() =>
  72. {
  73. DaoYouPanel.OpenPanel();
  74. CloseMenu();
  75. });
  76. Btn_Tower.onClick.AddListener(() =>
  77. {
  78. TowerPanel.OpenPanel(1);
  79. CloseMenu();
  80. });
  81. }
  82. private void CloseMenu()
  83. {
  84. UIManager.Instance.DormancyGComponent(_backgroundCom);
  85. _backgroundCom = null;
  86. MenuRoot.SetActive(false);
  87. }
  88. public async void Bnt_ShengShi_Click()
  89. {
  90. await DivineSenceInfoPanel.OpenPanel((count, useItems) => { Bnt_shengShi_onClick(count, useItems); });
  91. }
  92. public async void Btn_Shop_Click()
  93. {
  94. CloseMenu();
  95. if (currentOpenUIPanel is ShopPanel)
  96. {
  97. return;
  98. }
  99. UIPanel uiPanel = currentOpenUIPanel;
  100. CombatDrive.Instance.CombatController.isUpdate = false;
  101. ShopPanel shopPanel = await ShopPanel.OpenPanel();
  102. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  103. uiPanel is MainHeroPanel)
  104. {
  105. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  106. }
  107. if (!shopPanel.IsClose)
  108. await shopPanel.UIClosed();
  109. CombatDrive.Instance.CombatController.isUpdate = true;
  110. }
  111. public async void Btn_GongFa_Click()
  112. {
  113. CloseMenu();
  114. if (currentOpenUIPanel is SkillSelectPanel)
  115. {
  116. return;
  117. }
  118. UIPanel uiPanel = currentOpenUIPanel;
  119. SkillSelectPanel skillSelectPanel = await SkillSelectPanel.OpenSkillSelectPanel();
  120. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  121. uiPanel is MainHeroPanel)
  122. {
  123. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  124. }
  125. }
  126. public async void Btn_HeroInfomation_Click()
  127. {
  128. CloseMenu();
  129. if (currentOpenUIPanel is MainHeroPanel)
  130. {
  131. return;
  132. }
  133. UIPanel uiPanel = currentOpenUIPanel;
  134. MainHeroPanel mainHeroPanel = await MainHeroPanel.OpenPanel();
  135. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  136. uiPanel is MainHeroPanel)
  137. {
  138. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  139. }
  140. if (!mainHeroPanel.IsClose)
  141. await mainHeroPanel.UIClosed();
  142. }
  143. public async void Bne_dongfu_Click()
  144. {
  145. CloseMenu();
  146. if (currentOpenUIPanel is CaveMainPanel)
  147. {
  148. return;
  149. }
  150. UIPanel uiPanel = currentOpenUIPanel;
  151. CombatDrive.Instance.CombatController.isUpdate = false;
  152. CaveMainPanel heroInformationPanel = await CaveMainPanel.OpenPanel();
  153. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  154. uiPanel is MainHeroPanel)
  155. {
  156. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  157. }
  158. if (!heroInformationPanel.IsClose)
  159. await heroInformationPanel.UIClosed();
  160. CombatDrive.Instance.CombatController.isUpdate = true;
  161. }
  162. private async CTask OpenSelectSkillPanel()
  163. {
  164. }
  165. private async void Bnt_shengShi_onClick(int count, List<ItemInfo> useItems)
  166. {
  167. if (AccountFileInfo.Instance.playerData.divineSensePoint <
  168. PlayerManager.Instance.gameConstantConfig.DetectEventCount)
  169. {
  170. await DivineSenceRestoredPanel.OpenPanel();
  171. // await TipMessagePanel.OpenTipMessagePanel("神识值不够!");
  172. return;
  173. }
  174. if (count == 0)
  175. {
  176. return;
  177. }
  178. EventSystemManager.Instance.CancelEvent();
  179. if (EventSystemManager.Instance.isTriggerEvent)
  180. return;
  181. AudioManager.Instance.PlayAudio("ui_shengshitansuo.wav");
  182. if (PlayerGuideManager.Instance.curPhase == 2)
  183. PlayerGuideManager.Instance.StepInit();
  184. if (PlayerGuideManager.Instance.curPhase == 3)
  185. PlayerGuideManager.Instance.StepInit();
  186. EventSystemManager.Instance.isTriggerEvent = true;
  187. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  188. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  189. .playerHeroEntity.GameObject.transform);
  190. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  191. await TimerComponent.Instance.WaitAsync(1200);
  192. EventSystemManager.Instance.isTriggerEvent = false;
  193. if (eventLists == null || eventLists.Count == 0)
  194. {
  195. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  196. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  197. // {
  198. // PlayerGuideManager.Instance.NextGuide();
  199. // }
  200. return;
  201. }
  202. if (eventLists != null && eventLists.Count > 0)
  203. {
  204. await DivineSenceEventPreviewPanel.OpenPanel();
  205. }
  206. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  207. // {
  208. // PlayerGuideManager.Instance.NextGuide();
  209. // }
  210. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  211. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  212. }
  213. public void CustomInit(UIPanel uiPanel)
  214. {
  215. currentOpenUIPanel = uiPanel;
  216. UpdateUitoggleState();
  217. }
  218. private void UpdateUitoggleState()
  219. {
  220. if (currentOpenUIPanel is MainPanel)
  221. {
  222. Icon_Di.gameObject.SetActive(true);
  223. Btn_Back.gameObject.SetActive(false);
  224. bnt_shengShi.gameObject.SetActive(true);
  225. BtnRoot.gameObject.SetActive(true);
  226. }
  227. else if (currentOpenUIPanel is CaveMainPanel || currentOpenUIPanel is SkillSelectPanel ||
  228. currentOpenUIPanel is ShopPanel ||
  229. currentOpenUIPanel is MainHeroPanel)
  230. {
  231. Icon_Di.gameObject.SetActive(true);
  232. Btn_Back.gameObject.SetActive(true);
  233. bnt_shengShi.gameObject.SetActive(false);
  234. BtnRoot.gameObject.SetActive(true);
  235. }
  236. else
  237. {
  238. Icon_Di.gameObject.SetActive(false);
  239. BtnRoot.gameObject.SetActive(false);
  240. Btn_Back.gameObject.SetActive(true);
  241. bnt_shengShi.gameObject.SetActive(false);
  242. }
  243. if (currentOpenUIPanel is CaveMainPanel)
  244. {
  245. Toggle_BtnRoot.ShowTargetIndex(2);
  246. }
  247. else if (currentOpenUIPanel is SkillSelectPanel)
  248. {
  249. Toggle_BtnRoot.ShowTargetIndex(1);
  250. }
  251. else if (currentOpenUIPanel is ShopPanel)
  252. {
  253. Toggle_BtnRoot.ShowTargetIndex(3);
  254. }
  255. else if (currentOpenUIPanel is MainHeroPanel)
  256. {
  257. Toggle_BtnRoot.ShowTargetIndex(0);
  258. }
  259. else
  260. {
  261. Toggle_BtnRoot.Hide();
  262. }
  263. }
  264. public async static CTask OpenPanel(UIPanel uiPanel)
  265. {
  266. AppBarPanel appBarPanel = null;
  267. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  268. {
  269. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  270. }
  271. else
  272. {
  273. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  274. await appBarPanel.Show();
  275. }
  276. appBarPanel.CustomInit(uiPanel);
  277. }
  278. public async static CTask ClosePanel()
  279. {
  280. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  281. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  282. }
  283. }
  284. }