AppBarPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 (count == 0)
  168. {
  169. return;
  170. }
  171. EventSystemManager.Instance.CancelEvent();
  172. if (EventSystemManager.Instance.isTriggerEvent)
  173. return;
  174. AudioManager.Instance.PlayAudio("ui_shengshitansuo.wav");
  175. if (PlayerGuideManager.Instance.curPhase == 2)
  176. PlayerGuideManager.Instance.StepInit();
  177. if (PlayerGuideManager.Instance.curPhase == 3)
  178. PlayerGuideManager.Instance.StepInit();
  179. EventSystemManager.Instance.isTriggerEvent = true;
  180. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  181. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  182. .playerHeroEntity.GameObject.transform);
  183. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  184. await TimerComponent.Instance.WaitAsync(1200);
  185. EventSystemManager.Instance.isTriggerEvent = false;
  186. if (eventLists == null || eventLists.Count == 0)
  187. {
  188. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  189. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  190. // {
  191. // PlayerGuideManager.Instance.NextGuide();
  192. // }
  193. return;
  194. }
  195. if (eventLists != null && eventLists.Count > 0)
  196. {
  197. await DivineSenceEventPreviewPanel.OpenPanel();
  198. }
  199. // if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  200. // {
  201. // PlayerGuideManager.Instance.NextGuide();
  202. // }
  203. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  204. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  205. }
  206. public void CustomInit(UIPanel uiPanel)
  207. {
  208. currentOpenUIPanel = uiPanel;
  209. UpdateUitoggleState();
  210. }
  211. private void UpdateUitoggleState()
  212. {
  213. if (currentOpenUIPanel is MainPanel)
  214. {
  215. Icon_Di.gameObject.SetActive(true);
  216. Btn_Back.gameObject.SetActive(false);
  217. bnt_shengShi.gameObject.SetActive(true);
  218. BtnRoot.gameObject.SetActive(true);
  219. }
  220. else if (currentOpenUIPanel is CaveMainPanel || currentOpenUIPanel is SkillSelectPanel ||
  221. currentOpenUIPanel is ShopPanel ||
  222. currentOpenUIPanel is MainHeroPanel)
  223. {
  224. Icon_Di.gameObject.SetActive(true);
  225. Btn_Back.gameObject.SetActive(true);
  226. bnt_shengShi.gameObject.SetActive(false);
  227. BtnRoot.gameObject.SetActive(true);
  228. }
  229. else
  230. {
  231. Icon_Di.gameObject.SetActive(false);
  232. BtnRoot.gameObject.SetActive(false);
  233. Btn_Back.gameObject.SetActive(true);
  234. bnt_shengShi.gameObject.SetActive(false);
  235. }
  236. if (currentOpenUIPanel is CaveMainPanel)
  237. {
  238. Toggle_BtnRoot.ShowTargetIndex(2);
  239. }
  240. else if (currentOpenUIPanel is SkillSelectPanel)
  241. {
  242. Toggle_BtnRoot.ShowTargetIndex(1);
  243. }
  244. else if (currentOpenUIPanel is ShopPanel)
  245. {
  246. Toggle_BtnRoot.ShowTargetIndex(3);
  247. }
  248. else if (currentOpenUIPanel is MainHeroPanel)
  249. {
  250. Toggle_BtnRoot.ShowTargetIndex(0);
  251. }
  252. else
  253. {
  254. Toggle_BtnRoot.Hide();
  255. }
  256. }
  257. public async static CTask OpenPanel(UIPanel uiPanel)
  258. {
  259. AppBarPanel appBarPanel = null;
  260. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  261. {
  262. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  263. }
  264. else
  265. {
  266. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  267. await appBarPanel.Show();
  268. }
  269. appBarPanel.CustomInit(uiPanel);
  270. RedDotManager.Instance.AllRedDotUpDate();
  271. }
  272. public async static CTask ClosePanel()
  273. {
  274. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  275. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  276. }
  277. }
  278. }