DivineSenceEventPreviewPanel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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 (mainShengShiEventWidgetType2 == null)
  105. mainShengShiEventWidgetType2 =
  106. await UIManager.Instance.CreateGComponentForObject<ShengShiEventWidgetType2>(
  107. ShengShiEventWidgetType2Game, null, ShengShiEventWidgetType2Root);
  108. if (eventList != null)
  109. {
  110. mainShengShiEventWidgetType2.own.SetActive(true);
  111. mainShengShiEventWidgetType2.CustomInit(eventList, GoOnClick);
  112. mainShengShiEventWidgetType2.OnClick = OnClick;
  113. }
  114. else
  115. {
  116. mainShengShiEventWidgetType2.own.SetActive(true);
  117. mainShengShiEventWidgetType2.CustomInit1();
  118. }
  119. }
  120. //道友
  121. else
  122. {
  123. toggleList.ShowTargetIndex(1);
  124. mainShengShiEventWidgetType2?.own.SetActive(false);
  125. // UIManager.Instance.DormancyGComponent(mainShengShiEventWidgetType2);
  126. // mainShengShiEventWidgetType2 = null;
  127. TitleRoot.SetActive(false);
  128. Rect_Sv.SetParent(Sv2root);
  129. Rect_Sv.offsetMax = Vector2.zero;
  130. Rect_Sv.offsetMin = Vector2.zero;
  131. Text_Tips.gameObject.SetActive(showEventList.Count > 0);
  132. }
  133. var divineSenseConfig =
  134. ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  135. int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax /
  136. PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  137. maxCount = maxCount > divineSenseConfig.MaxNum ? divineSenseConfig.MaxNum : maxCount;
  138. Text_ShenShiCount.text =
  139. LanguageManager.Instance.Text(10239, EventSystemManager.Instance.GetShenShiCount(), maxCount);
  140. SaiXuan(saixuanType);
  141. showEventList.Sort(Sort);
  142. await Content.Init(this, showEventList.Count);
  143. }
  144. public int Sort(AccountFileInfo.EventList a, AccountFileInfo.EventList b)
  145. {
  146. if (a.isCompleted && !b.isCompleted)
  147. return 1;
  148. if (!a.isCompleted && b.isCompleted)
  149. return -1;
  150. return 0;
  151. }
  152. public void SaiXuan(int type)
  153. {
  154. showEventList.Clear();
  155. if (type == 1)
  156. {
  157. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  158. {
  159. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  160. if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4)
  161. {
  162. showEventList.Add(eventList);
  163. }
  164. }
  165. }
  166. else
  167. {
  168. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  169. {
  170. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  171. if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4)
  172. {
  173. showEventList.Add(eventList);
  174. }
  175. }
  176. }
  177. }
  178. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  179. {
  180. if (index < 0 || index >= showEventList.Count)
  181. {
  182. return null;
  183. }
  184. ShengShiEventWidgetType2 shengShiEventWidgetType2 =
  185. await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  186. shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick);
  187. shengShiEventWidgetType2.OnClick = OnClick;
  188. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  189. return shengShiEventWidgetType2;
  190. }
  191. private void GoOnClick(ItemWidgetBasic obj)
  192. {
  193. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  194. EventSystemManager.Instance.CancelEvent();
  195. if (EventSystemManager.Instance.isTriggerEvent)
  196. return;
  197. if (shengShiEventWidgetType2.eventList.isCompleted)
  198. {
  199. return;
  200. }
  201. EventConfig eventConfig =
  202. ConfigComponent.Instance.Get<EventConfig>(shengShiEventWidgetType2.eventList.eventID);
  203. if (eventConfig.EventTriggerType == 4)
  204. {
  205. if (shengShiEventWidgetType2.eventList.isCompleted1)
  206. {
  207. EventSystemManager.Instance.CompleteEvent(shengShiEventWidgetType2.eventList);
  208. // UpdateContent();
  209. return;
  210. }
  211. }
  212. isTriggerEvent = true;
  213. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  214. {
  215. isTriggerEvent = false;
  216. // UpdateContent();
  217. });
  218. }
  219. private void OnClick(ItemWidgetBasic obj)
  220. {
  221. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  222. //条件完成 任务没有完成 是最后一步就直接开始任务
  223. if (shengShiEventWidgetType2.isComplete && !shengShiEventWidgetType2.eventList.isCompleted)
  224. {
  225. if (shengShiEventWidgetType2.evenkConfig.ResultType == 0 ||
  226. shengShiEventWidgetType2.evenkConfig.ResultType == 3)
  227. {
  228. GoOnClick(shengShiEventWidgetType2);
  229. return;
  230. }
  231. }
  232. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList, 1);
  233. }
  234. public void HindIScorllListWidget(IScorllListWidget widget)
  235. {
  236. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  237. }
  238. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  239. {
  240. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  241. await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null, UILayer.Middle);
  242. return divineSenceEventPreviewPanel;
  243. }
  244. public async override CTask Close()
  245. {
  246. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  247. shengShiEventWidgetTypeList.Clear();
  248. EventSystemManager.Instance.isOpenUi = false;
  249. saixuanType = 1;
  250. mainShengShiEventWidgetType2?.DormancyObj();
  251. mainShengShiEventWidgetType2 = null;
  252. isTriggerEvent = false;
  253. await base.Close();
  254. }
  255. }
  256. }