DivineSenceEventPreviewPanel.cs 9.3 KB

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