AppBarPanel.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. if(PlayerGuideManager.Instance.curPhase == 1)
  158. PlayerGuideManager.Instance.StepInit();
  159. EventSystemManager.Instance.isTriggerEvent = true;
  160. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  161. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  162. .playerHeroEntity.GameObject.transform);
  163. List<AccountFileInfo.EventList> eventLists = EventSystemManager.Instance.UseDivinesense(count, useItems);
  164. await TimerComponent.Instance.WaitAsync(1200);
  165. EventSystemManager.Instance.isTriggerEvent = false;
  166. if (eventLists == null || eventLists.Count == 0)
  167. {
  168. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  169. if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  170. {
  171. PlayerGuideManager.Instance.NextGuide();
  172. }
  173. return;
  174. }
  175. if (eventLists != null && eventLists.Count > 0)
  176. {
  177. await DivineSenceEventPreviewPanel.OpenPanel();
  178. }
  179. if (PlayerGuideManager.Instance.GuideIsCanDo(1, 2))
  180. {
  181. PlayerGuideManager.Instance.NextGuide();
  182. }
  183. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  184. EventManager.Instance.Dispatch(CustomEventType.ShengShiOnClick, null);
  185. }
  186. public void CustomInit(UIPanel uiPanel)
  187. {
  188. if (uiPanel is MainPanel)
  189. {
  190. Btn_Back.gameObject.SetActive(false);
  191. bnt_shengShi.gameObject.SetActive(true);
  192. BtnRoot.gameObject.SetActive(true);
  193. currentOpenUIPanel = uiPanel;
  194. }
  195. else if (uiPanel is CaveMainPanel || uiPanel is SkillSelectPanel || uiPanel is ShopPanel ||
  196. uiPanel is MainHeroPanel)
  197. {
  198. Btn_Back.gameObject.SetActive(true);
  199. bnt_shengShi.gameObject.SetActive(false);
  200. BtnRoot.gameObject.SetActive(true);
  201. currentOpenUIPanel = uiPanel;
  202. }
  203. else
  204. {
  205. BtnRoot.gameObject.SetActive(false);
  206. Btn_Back.gameObject.SetActive(true);
  207. bnt_shengShi.gameObject.SetActive(false);
  208. currentOpenUIPanel = uiPanel;
  209. }
  210. if (uiPanel is CaveMainPanel)
  211. {
  212. Toggle_BtnRoot.ShowTargetIndex(2);
  213. }
  214. else if (uiPanel is SkillSelectPanel)
  215. {
  216. Toggle_BtnRoot.ShowTargetIndex(1);
  217. }
  218. else if (uiPanel is ShopPanel)
  219. {
  220. Toggle_BtnRoot.ShowTargetIndex(3);
  221. }
  222. else if (uiPanel is MainHeroPanel)
  223. {
  224. Toggle_BtnRoot.ShowTargetIndex(0);
  225. }
  226. else
  227. {
  228. Toggle_BtnRoot.Hide();
  229. }
  230. }
  231. public async static CTask OpenPanel(UIPanel uiPanel)
  232. {
  233. AppBarPanel appBarPanel = null;
  234. if (UIManager.Instance.GetComponent<AppBarPanel>() == null)
  235. {
  236. appBarPanel = await UIManager.Instance.LoadAndOpenPanel<AppBarPanel>(null, UILayer.Top, isFocus: false);
  237. }
  238. else
  239. {
  240. appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  241. await appBarPanel.Show();
  242. }
  243. appBarPanel.CustomInit(uiPanel);
  244. }
  245. public async static CTask ClosePanel()
  246. {
  247. // UIManager.Instance.HideUIUIPanel<AppBarPanel>();
  248. UIManager.Instance.GetComponent<AppBarPanel>()?.Hide();
  249. }
  250. }
  251. }