DivineSenceEventPreviewPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using System.Collections.Generic;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using UnityEngine;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "DivineSenceEventPreviewPanel")]
  10. public partial class DivineSenceEventPreviewPanel : UIPanel, IScrollListContent
  11. {
  12. public List<AccountFileInfo.EventList> showEventList = new List<AccountFileInfo.EventList>();
  13. List<ShengShiEventWidgetType2> shengShiEventWidgetTypeList = new List<ShengShiEventWidgetType2>();
  14. public ShengShiEventWidgetType2 mainShengShiEventWidgetType2;
  15. private int saixuanType = 1;
  16. bool isTriggerEvent = false;
  17. private void Init()
  18. {
  19. // isPopUi = true;
  20. isAddStack = true;
  21. }
  22. public override CTask GetFocus()
  23. {
  24. if (PlayerGuideManager.Instance.GuideIsCanDo(2, 2))
  25. {
  26. PlayerGuideManager.Instance.NextGuide();
  27. }
  28. if (PlayerGuideManager.Instance.GuideIsCanDo(3, 1))
  29. {
  30. PlayerGuideManager.Instance.NextGuide();
  31. }
  32. if (isTriggerEvent)
  33. GObjectPoolInterface.SetActive(false);
  34. AppBarPanel.OpenPanel(this);
  35. return base.GetFocus();
  36. }
  37. protected override void AddEvent()
  38. {
  39. EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  40. EventManager.Instance.AddEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);
  41. }
  42. private void CompleteUpdate(IEventData e)
  43. {
  44. UpdateContent();
  45. }
  46. public override CTask Show()
  47. {
  48. return base.Show();
  49. }
  50. protected override void DelEvent()
  51. {
  52. EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  53. EventManager.Instance.RemoveEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);
  54. }
  55. public override void AddButtonEvent()
  56. {
  57. Btn_Log.onClick.AddListener(() => { XianTuLogPanel.OpenPanel(); });
  58. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  59. Btn_ShenShi.onClick.AddListener(async () =>
  60. {
  61. if (saixuanType == 1)
  62. return;
  63. saixuanType = 1;
  64. UpdateContent();
  65. });
  66. Btn_DaoYou.onClick.AddListener(async () =>
  67. {
  68. if (saixuanType == 2)
  69. return;
  70. saixuanType = 2;
  71. UpdateContent();
  72. });
  73. }
  74. private void RemoveEvent(IEventData e)
  75. {
  76. // UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  77. // Content.Init(this, showEventList.Count);
  78. UpdateContent();
  79. }
  80. public async override CTask<bool> AsyncInit(object[] uiData)
  81. {
  82. await UpdateContent();
  83. return await base.AsyncInit(uiData);
  84. }
  85. private async CTask UpdateContent()
  86. {
  87. foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList)
  88. {
  89. UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2);
  90. }
  91. shengShiEventWidgetTypeList.Clear();
  92. //神识
  93. if (saixuanType == 1)
  94. {
  95. toggleList.ShowTargetIndex(0);
  96. TitleRoot.SetActive(true);
  97. Rect_Sv.SetParent(Sv1root);
  98. Rect_Sv.offsetMax = Vector2.zero;
  99. Rect_Sv.offsetMin = Vector2.zero;
  100. // Rect_Sv.sizeDelta = new Vector2(718.82f, 844.7f);
  101. // Rect_Sv.anchoredPosition = new Vector2(2.61f, -190.52f);
  102. Text_Tips.gameObject.SetActive(false);
  103. AccountFileInfo.EventList eventList = EventSystemManager.Instance.GetMainEventDta();
  104. if (eventList != null)
  105. {
  106. if (mainShengShiEventWidgetType2 == null)
  107. mainShengShiEventWidgetType2 =
  108. await UIManager.Instance.CreateGComponentForObject<ShengShiEventWidgetType2>(
  109. ShengShiEventWidgetType2Game, null, ShengShiEventWidgetType2Root);
  110. mainShengShiEventWidgetType2.own.SetActive(true);
  111. mainShengShiEventWidgetType2.CustomInit(eventList, GoOnClick);
  112. mainShengShiEventWidgetType2.OnClick = OnClick;
  113. }
  114. }
  115. //道友
  116. else
  117. {
  118. toggleList.ShowTargetIndex(1);
  119. mainShengShiEventWidgetType2?.own.SetActive(false);
  120. // UIManager.Instance.DormancyGComponent(mainShengShiEventWidgetType2);
  121. // mainShengShiEventWidgetType2 = null;
  122. TitleRoot.SetActive(false);
  123. Rect_Sv.SetParent(Sv2root);
  124. Rect_Sv.offsetMax = Vector2.zero;
  125. Rect_Sv.offsetMin = Vector2.zero;
  126. Text_Tips.gameObject.SetActive(showEventList.Count > 0);
  127. }
  128. var divineSenseConfig =
  129. ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  130. int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax /
  131. PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  132. maxCount = maxCount > divineSenseConfig.MaxNum ? divineSenseConfig.MaxNum : maxCount;
  133. Text_ShenShiCount.text =
  134. LanguageManager.Instance.Text(10239, EventSystemManager.Instance.GetShenShiCount(), maxCount);
  135. SaiXuan(saixuanType);
  136. showEventList.Sort(Sort);
  137. await Content.Init(this, showEventList.Count);
  138. }
  139. public int Sort(AccountFileInfo.EventList a, AccountFileInfo.EventList b)
  140. {
  141. if (a.isCompleted && !b.isCompleted)
  142. return 1;
  143. if (!a.isCompleted && b.isCompleted)
  144. return -1;
  145. return 0;
  146. }
  147. public void SaiXuan(int type)
  148. {
  149. showEventList.Clear();
  150. if (type == 1)
  151. {
  152. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  153. {
  154. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  155. if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4)
  156. {
  157. showEventList.Add(eventList);
  158. }
  159. }
  160. }
  161. else
  162. {
  163. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  164. {
  165. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  166. if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4)
  167. {
  168. showEventList.Add(eventList);
  169. }
  170. }
  171. }
  172. }
  173. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  174. {
  175. if (index < 0 || index >= showEventList.Count)
  176. {
  177. return null;
  178. }
  179. ShengShiEventWidgetType2 shengShiEventWidgetType2 =
  180. await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  181. shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick);
  182. shengShiEventWidgetType2.OnClick = OnClick;
  183. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  184. return shengShiEventWidgetType2;
  185. }
  186. private void GoOnClick(ItemWidgetBasic obj)
  187. {
  188. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  189. EventSystemManager.Instance.CancelEvent();
  190. if (EventSystemManager.Instance.isTriggerEvent)
  191. return;
  192. if (shengShiEventWidgetType2.eventList.isCompleted)
  193. {
  194. return;
  195. }
  196. EventConfig eventConfig =
  197. ConfigComponent.Instance.Get<EventConfig>(shengShiEventWidgetType2.eventList.eventID);
  198. if (eventConfig.EventTriggerType == 4)
  199. {
  200. if (shengShiEventWidgetType2.eventList.isCompleted1)
  201. {
  202. EventSystemManager.Instance.CompleteEvent(shengShiEventWidgetType2.eventList);
  203. // UpdateContent();
  204. return;
  205. }
  206. }
  207. isTriggerEvent = true;
  208. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  209. {
  210. isTriggerEvent = false;
  211. // UpdateContent();
  212. });
  213. }
  214. private void OnClick(ItemWidgetBasic obj)
  215. {
  216. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  217. //条件完成 任务没有完成 是最后一步就直接开始任务
  218. if (shengShiEventWidgetType2.isComplete && !shengShiEventWidgetType2.eventList.isCompleted)
  219. {
  220. if (shengShiEventWidgetType2.evenkConfig.ResultType == 0 ||
  221. shengShiEventWidgetType2.evenkConfig.ResultType == 3)
  222. {
  223. GoOnClick(shengShiEventWidgetType2);
  224. return;
  225. }
  226. }
  227. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList, 1);
  228. }
  229. public void HindIScorllListWidget(IScorllListWidget widget)
  230. {
  231. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  232. }
  233. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  234. {
  235. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  236. await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null, UILayer.Middle);
  237. return divineSenceEventPreviewPanel;
  238. }
  239. public async override CTask Close()
  240. {
  241. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  242. shengShiEventWidgetTypeList.Clear();
  243. EventSystemManager.Instance.isOpenUi = false;
  244. saixuanType = 1;
  245. mainShengShiEventWidgetType2?.DormancyObj();
  246. mainShengShiEventWidgetType2 = null;
  247. isTriggerEvent = false;
  248. await base.Close();
  249. }
  250. }
  251. }