DivineSenceEventPreviewPanel.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. var divineSenseConfig =
  119. ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  120. int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax /
  121. PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  122. maxCount = maxCount > divineSenseConfig.MaxNum ? divineSenseConfig.MaxNum : maxCount;
  123. Text_ShenShiCount.text =
  124. LanguageManager.Instance.Text(10239, EventSystemManager.Instance.GetShenShiCount(), maxCount);
  125. SaiXuan(saixuanType);
  126. showEventList.Sort(Sort);
  127. await Content.Init(this, showEventList.Count);
  128. }
  129. public int Sort(AccountFileInfo.EventList a, AccountFileInfo.EventList b)
  130. {
  131. if (a.isCompleted && !b.isCompleted)
  132. return 1;
  133. if (!a.isCompleted && b.isCompleted)
  134. return -1;
  135. return 0;
  136. }
  137. public void SaiXuan(int type)
  138. {
  139. showEventList.Clear();
  140. if (type == 1)
  141. {
  142. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  143. {
  144. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  145. if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4)
  146. {
  147. showEventList.Add(eventList);
  148. }
  149. }
  150. }
  151. else
  152. {
  153. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  154. {
  155. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  156. if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4)
  157. {
  158. showEventList.Add(eventList);
  159. }
  160. }
  161. }
  162. }
  163. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  164. {
  165. if (index < 0 || index >= showEventList.Count)
  166. {
  167. return null;
  168. }
  169. ShengShiEventWidgetType2 shengShiEventWidgetType2 =
  170. await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  171. shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick);
  172. shengShiEventWidgetType2.OnClick = OnClick;
  173. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  174. return shengShiEventWidgetType2;
  175. }
  176. private void GoOnClick(ItemWidgetBasic obj)
  177. {
  178. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  179. EventSystemManager.Instance.CancelEvent();
  180. if (EventSystemManager.Instance.isTriggerEvent)
  181. return;
  182. if (shengShiEventWidgetType2.eventList.isCompleted)
  183. {
  184. return;
  185. }
  186. isTriggerEvent = true;
  187. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  188. {
  189. isTriggerEvent = false;
  190. UpdateContent();
  191. });
  192. }
  193. private void OnClick(ItemWidgetBasic obj)
  194. {
  195. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  196. //条件完成 任务没有完成 是最后一步就直接开始任务
  197. if (shengShiEventWidgetType2.isComplete && !shengShiEventWidgetType2.eventList.isCompleted)
  198. {
  199. if (shengShiEventWidgetType2.evenkConfig.ResultType == 0 ||
  200. shengShiEventWidgetType2.evenkConfig.ResultType == 3)
  201. {
  202. GoOnClick(shengShiEventWidgetType2);
  203. return;
  204. }
  205. }
  206. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList, 1);
  207. }
  208. public void HindIScorllListWidget(IScorllListWidget widget)
  209. {
  210. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  211. }
  212. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  213. {
  214. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  215. await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null, UILayer.Middle);
  216. return divineSenceEventPreviewPanel;
  217. }
  218. public override void Close()
  219. {
  220. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  221. shengShiEventWidgetTypeList.Clear();
  222. EventSystemManager.Instance.isOpenUi = false;
  223. saixuanType = 1;
  224. mainShengShiEventWidgetType2 = null;
  225. isTriggerEvent = false;
  226. base.Close();
  227. }
  228. }
  229. }