AppBarPanel.cs 11 KB

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