AppBarPanel.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. if (PlayerGuideManager.Instance.GuideIsCanDo(1, 1))
  73. {
  74. PlayerGuideManager.Instance.NextGuide();
  75. }
  76. }
  77. public async void Btn_Shop_Click()
  78. {
  79. if (currentOpenUIPanel is ShopPanel)
  80. {
  81. return;
  82. }
  83. UIPanel uiPanel = currentOpenUIPanel;
  84. CombatDrive.Instance.CombatController.isUpdate = false;
  85. ShopPanel shopPanel = await ShopPanel.OpenPanel();
  86. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  87. uiPanel is MainHeroPanel)
  88. {
  89. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  90. }
  91. if (!shopPanel.IsClose)
  92. await shopPanel.UIClosed();
  93. CombatDrive.Instance.CombatController.isUpdate = true;
  94. }
  95. public async void Btn_GongFa_Click()
  96. {
  97. if (currentOpenUIPanel is SkillSelectPanel)
  98. {
  99. return;
  100. }
  101. UIPanel uiPanel = currentOpenUIPanel;
  102. SkillSelectPanel skillSelectPanel = await SkillSelectPanel.OpenSkillSelectPanel();
  103. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  104. uiPanel is MainHeroPanel)
  105. {
  106. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  107. }
  108. }
  109. public async void Btn_HeroInfomation_Click()
  110. {
  111. if (currentOpenUIPanel is MainHeroPanel)
  112. {
  113. return;
  114. }
  115. UIPanel uiPanel = currentOpenUIPanel;
  116. MainHeroPanel mainHeroPanel = await MainHeroPanel.OpenPanel();
  117. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  118. uiPanel is MainHeroPanel)
  119. {
  120. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  121. }
  122. if (!mainHeroPanel.IsClose)
  123. await mainHeroPanel.UIClosed();
  124. }
  125. public async void Bne_dongfu_Click()
  126. {
  127. if (currentOpenUIPanel is CaveMainPanel)
  128. {
  129. return;
  130. }
  131. UIPanel uiPanel = currentOpenUIPanel;
  132. CombatDrive.Instance.CombatController.isUpdate = false;
  133. CaveMainPanel heroInformationPanel = await CaveMainPanel.OpenPanel();
  134. if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  135. uiPanel is MainHeroPanel)
  136. {
  137. UIManager.Instance.HideUIUIPanel(uiPanel, isBreadcrumbBarPanel: false);
  138. }
  139. if (!heroInformationPanel.IsClose)
  140. await heroInformationPanel.UIClosed();
  141. CombatDrive.Instance.CombatController.isUpdate = true;
  142. }
  143. private async CTask OpenSelectSkillPanel()
  144. {
  145. }
  146. private async void Bnt_shengShi_onClick(int count, List<ItemInfo> useItems)
  147. {
  148. if (AccountFileInfo.Instance.playerData.divineSensePoint <
  149. PlayerManager.Instance.gameConstantConfig.DetectEventCount)
  150. {
  151. TipMessagePanel.OpenTipMessagePanel("神识值不够!");
  152. return;
  153. }
  154. EventSystemManager.Instance.CancelEvent();
  155. if (EventSystemManager.Instance.isTriggerEvent)
  156. return;
  157. PlayerGuideManager.Instance.StepInit();
  158. EventSystemManager.Instance.isTriggerEvent = true;
  159. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  160. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  161. .playerHeroEntity.GameObject.transform);
  162. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  163. await TimerComponent.Instance.WaitAsync(1200);
  164. EventSystemManager.Instance.isTriggerEvent = false;
  165. if (eventLists == null || eventLists.Count == 0)
  166. {
  167. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  168. if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  169. {
  170. PlayerGuideManager.Instance.NextGuide();
  171. }
  172. return;
  173. }
  174. if (eventLists != null && eventLists.Count > 0)
  175. {
  176. await DivineSenceEventPreviewPanel.OpenPanel();
  177. }
  178. if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  179. {
  180. PlayerGuideManager.Instance.NextGuide();
  181. }
  182. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  183. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  184. }
  185. public void CustomInit(UIPanel uiPanel)
  186. {
  187. if (uiPanel is MainPanel)
  188. {
  189. Btn_Back.gameObject.SetActive(false);
  190. bnt_shengShi.gameObject.SetActive(true);
  191. BtnRoot.gameObject.SetActive(true);
  192. currentOpenUIPanel = uiPanel;
  193. }
  194. else if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  195. uiPanel is MainHeroPanel)
  196. {
  197. Btn_Back.gameObject.SetActive(true);
  198. bnt_shengShi.gameObject.SetActive(false);
  199. BtnRoot.gameObject.SetActive(true);
  200. currentOpenUIPanel = uiPanel;
  201. }
  202. else
  203. {
  204. BtnRoot.gameObject.SetActive(false);
  205. Btn_Back.gameObject.SetActive(true);
  206. bnt_shengShi.gameObject.SetActive(false);
  207. currentOpenUIPanel = uiPanel;
  208. }
  209. if (uiPanel is CaveMainPanel)
  210. {
  211. Toggle_BtnRoot.ShowTargetIndex(2);
  212. }
  213. else if (uiPanel is SkillSelectPanel)
  214. {
  215. Toggle_BtnRoot.ShowTargetIndex(1);
  216. }
  217. else if (uiPanel is ShopPanel)
  218. {
  219. Toggle_BtnRoot.ShowTargetIndex(3);
  220. }
  221. else if (uiPanel is MainHeroPanel)
  222. {
  223. Toggle_BtnRoot.ShowTargetIndex(0);
  224. }
  225. else
  226. {
  227. Toggle_BtnRoot.Hide();
  228. }
  229. }
  230. public async static CTask OpenPanel(UIPanel uiPanel)
  231. {
  232. AppBarPanel appBarPanel = null;
  233. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  234. {
  235. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  236. }
  237. else
  238. {
  239. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  240. await appBarPanel.Show();
  241. }
  242. appBarPanel.CustomInit(uiPanel);
  243. }
  244. public async static CTask ClosePanel()
  245. {
  246. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  247. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  248. }
  249. }
  250. }