DivineSenceEventPreviewPanel.cs 10 KB

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