DivineSenceEventPreviewPanel.cs 9.2 KB

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