DivineSenceEventPreviewPanel.cs 8.5 KB

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