DivineSenceEventPreviewPanel.cs 8.8 KB

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