MainPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Core.Language;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using GameLogic.Combat;
  8. using GameLogic.Combat.CombatTool;
  9. using UnityEngine;
  10. namespace Fort23.Mono
  11. {
  12. [UIBinding(prefab = "MainPanel")]
  13. public partial class MainPanel : UIPanel
  14. {
  15. bool isShowSkillPanel = false;
  16. // private ShengShiEventWidget shengShiEventWidget;
  17. List<ShengShiConditionWidget> _shengShiConditionWidgets = new List<ShengShiConditionWidget>();
  18. private void Init()
  19. {
  20. isAddStack = true;
  21. IsShowAppBar = true;
  22. }
  23. protected override void AddEvent()
  24. {
  25. EventManager.Instance.AddEventListener(CustomEventType.ShengShiOnClick, ShengShiOnClick);
  26. EventManager.Instance.AddEventListener(CustomEventType.CompleteEvent, CompleteEvent);
  27. EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  28. EventManager.Instance.AddEventListener(CustomEventType.ChangeMap, ChangeMap);
  29. EventManager.Instance.AddEventListener(CustomEventType.DaoYouCounUpdate, DaoYouCounUpdate);
  30. }
  31. private void DaoYouCounUpdate(IEventData e)
  32. {
  33. UpdateDaoYouCoun();
  34. }
  35. public async override CTask GetFocus()
  36. {
  37. await AppBarPanel.OpenPanel(this);
  38. TitlePanel.ClosePanel();
  39. base.GetFocus();
  40. }
  41. private void RemoveEvent(IEventData e)
  42. {
  43. Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();
  44. CreatShengShiEvent();
  45. ChagneShenshiBtnActive();
  46. }
  47. private void CompleteEvent(IEventData e)
  48. {
  49. ChangeMap(null);
  50. Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();
  51. CreatShengShiEvent();
  52. ChagneShenshiBtnActive();
  53. Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;
  54. }
  55. public void UpdateDaoYouCoun()
  56. {
  57. int count = AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas.Count;
  58. // foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)
  59. // {
  60. // count += keyValuePair.Value.Count;
  61. // }
  62. if (count > 0)
  63. {
  64. Icon_Daoyou.gameObject.SetActive(true);
  65. Text_DaoyouCount.text = count.ToString();
  66. }
  67. else
  68. {
  69. Icon_Daoyou.gameObject.SetActive(false);
  70. }
  71. }
  72. private void ChagneShenshiBtnActive()
  73. {
  74. // Btn_Event.gameObject.SetActive(event > 0);
  75. }
  76. protected override void DelEvent()
  77. {
  78. EventManager.Instance.RemoveEventListener(CustomEventType.CompleteEvent, CompleteEvent);
  79. EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  80. EventManager.Instance.RemoveEventListener(CustomEventType.ShengShiOnClick, ShengShiOnClick);
  81. EventManager.Instance.RemoveEventListener(CustomEventType.ChangeMap, ChangeMap);
  82. EventManager.Instance.RemoveEventListener(CustomEventType.DaoYouCounUpdate, DaoYouCounUpdate);
  83. }
  84. public override void AddButtonEvent()
  85. {
  86. Btn_Chat.onClick.AddListener(() => { ChatPanel.OpenPanel(); });
  87. CameraSelect.onValueChanged.AddListener(CameraSelect_onValueChanged);
  88. Btn_Event.onClick.AddListener(() =>
  89. {
  90. EventSystemManager.Instance.isOpenUi = true;
  91. DivineSenceEventPreviewPanel.OpenPanel();
  92. });
  93. Btn_Map.onClick.AddListener(() => { LevelChoosePanel.OpenPanel(); });
  94. // Btn_DaoYou.onClick.AddListener(() => { DaoYouPanel.OpenPanel(); });
  95. //
  96. // Btn_Tower.onClick.AddListener(() => { TowerPanel.OpenPanel(1); });
  97. Btn_QianKunDai.onClick.AddListener(() => { QiankundaiPanel.OpenPanel(); });
  98. Btn_StartEvent.onClick.AddListener(() =>
  99. {
  100. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e => e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);
  101. if (eventList != null)
  102. {
  103. EventSystemManager.Instance.CancelEvent();
  104. if (EventSystemManager.Instance.isTriggerEvent)
  105. return;
  106. if (eventList.isCompleted)
  107. return;
  108. EventSystemManager.Instance.TriggerEvent(eventList);
  109. }
  110. });
  111. Btn_Daoyou.onClick.AddListener(() => { DaoYouGuaJiPanel.OpenPanel(); });
  112. Btn_Box.onClick.AddListener(() => { BoxPanel.OpenBoxPanel(); });
  113. }
  114. public override CTask<bool> AsyncInit(object[] uiData)
  115. {
  116. return base.AsyncInit(uiData);
  117. }
  118. public async override CTask Show()
  119. {
  120. await base.Show();
  121. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  122. Slider_SmallJD.maxValue = smallPlacesConfig.CompletionEventCount;
  123. Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;
  124. ChagneShenshiBtnActive();
  125. CreatShengShiEvent();
  126. ChangeMap(null);
  127. UpdateDaoYouCoun();
  128. bool isHIde = false;
  129. foreach (var skillInfo in PlayerManager.Instance.GongFaControl.allUseSkill)
  130. {
  131. if (skillInfo != null)
  132. {
  133. isHIde = true;
  134. break;
  135. }
  136. }
  137. if (!isHIde && !isShowSkillPanel)
  138. {
  139. isShowSkillPanel = true;
  140. SkillSelectPanel.OpenSkillSelectPanel();
  141. }
  142. CameraSelect.value = 0.2f;
  143. Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();
  144. Text_Jingjie.text =
  145. LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[0]) +
  146. LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[1]) +
  147. LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[2]);
  148. Slider_Exp.maxValue = PlayerManager.Instance.myHero.powerUpConfig.levelUpExp;
  149. // UpdateTaskInfo();
  150. }
  151. public void ChangeMap(IEventData e)
  152. {
  153. SmallPlacesConfig smallPlacesConfig =
  154. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  155. PlacesConfig placesConfig =
  156. ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);
  157. Text_ExplorationProgress.text =
  158. $"{LanguageManager.Instance.Text(placesConfig.placeName)} - {LanguageManager.Instance.Text(smallPlacesConfig.placeName)}";
  159. Slider_SmallJD.maxValue = smallPlacesConfig.CompletionEventCount;
  160. Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;
  161. }
  162. private void CameraSelect_onValueChanged(float value)
  163. {
  164. if (CombatController.currActiveCombat == null ||
  165. CombatController.currActiveCombat.CombatCameraControllder == null)
  166. {
  167. return;
  168. }
  169. CombatController.currActiveCombat.CombatCameraControllder.CameraSelect_onValueChanged(value);
  170. }
  171. private void ShengShiOnClick(IEventData e)
  172. {
  173. Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();
  174. ChagneShenshiBtnActive();
  175. CreatShengShiEvent();
  176. }
  177. public async void CreatShengShiEvent()
  178. {
  179. foreach (var shengShiConditionWidget in _shengShiConditionWidgets)
  180. {
  181. UIManager.Instance.DormancyGComponent(shengShiConditionWidget);
  182. }
  183. _shengShiConditionWidgets.Clear();
  184. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e => e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);
  185. if (eventList != null)
  186. {
  187. var randomEventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  188. Text_EventName.text = LanguageManager.Instance.Text(randomEventConfig.EventName);
  189. Text_EventTag.text = EventHelper.GetEventType(randomEventConfig.EventTag);
  190. AccountFileInfo.EventLinkData eventLinkData = eventList.eventLinks.FirstOrDefault(el => el.eventLinkId == eventList.curStep);
  191. EventLinkConfig evenkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(eventLinkData.eventLinkId);
  192. if (eventLinkData != null && eventLinkData.eventConditions != null && eventLinkData.eventConditions.Count > 0)
  193. {
  194. foreach (var eventConditionData in eventLinkData.eventConditions)
  195. {
  196. ShengShiConditionWidget shengShiConditionWidget = await UIManager.Instance.CreateGComponent<ShengShiConditionWidget>(null, EventConditionRoot);
  197. shengShiConditionWidget.CustomInit(eventConditionData);
  198. _shengShiConditionWidgets.Add(shengShiConditionWidget);
  199. }
  200. }
  201. else if (evenkConfig.EventConditionMessage != 0)
  202. {
  203. ShengShiConditionWidget shengShiConditionWidget = await UIManager.Instance.CreateGComponent<ShengShiConditionWidget>(null, EventConditionRoot);
  204. shengShiConditionWidget.CustomInit(LanguageManager.Instance.Text(evenkConfig.EventConditionMessage));
  205. _shengShiConditionWidgets.Add(shengShiConditionWidget);
  206. }
  207. }
  208. else
  209. {
  210. Text_EventName.text = "";
  211. Text_EventTag.text = "";
  212. }
  213. }
  214. [CustomMethod(CustomMethodType.Update)]
  215. public void Update()
  216. {
  217. if (Input.GetKeyDown(KeyCode.Y))
  218. {
  219. EventSystemManager.Instance.DetectRandomEvents();
  220. }
  221. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  222. float allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  223. Slider_Exp.value = PlayerManager.Instance.myHero.heroData.exp + allexp;
  224. }
  225. public async static CTask OpenPanel()
  226. {
  227. await UIManager.Instance.LoadAndOpenPanel<MainPanel>(null);
  228. }
  229. public override void Close()
  230. {
  231. foreach (var shengShiConditionWidget in _shengShiConditionWidgets)
  232. {
  233. UIManager.Instance.DormancyGComponent(shengShiConditionWidget);
  234. }
  235. _shengShiConditionWidgets.Clear();
  236. base.Close();
  237. }
  238. }
  239. }