DivineSenceEventPreviewPanel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. using System.Collections.Generic;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using Mono.Utility;
  7. using UnityEngine;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "DivineSenceEventPreviewPanel")]
  11. public partial class DivineSenceEventPreviewPanel : UIPanel, IScrollListContent
  12. {
  13. public List<AccountFileInfo.EventList> showEventList = new List<AccountFileInfo.EventList>();
  14. List<UIComponent> shengShiEventWidgetTypeList = new List<UIComponent>();
  15. public ShengShiEventWidgetType2 mainShengShiEventWidgetType2;
  16. private int saixuanType = 1;
  17. bool isTriggerEvent = false;
  18. private int creatCount;
  19. private void Init()
  20. {
  21. // isPopUi = true;
  22. isAddStack = true;
  23. }
  24. public override CTask GetFocus()
  25. {
  26. if (PlayerGuideManager.Instance.GuideIsCanDo(2, 2))
  27. {
  28. PlayerGuideManager.Instance.NextGuide();
  29. }
  30. if (PlayerGuideManager.Instance.GuideIsCanDo(3, 1))
  31. {
  32. PlayerGuideManager.Instance.NextGuide();
  33. }
  34. if (isTriggerEvent)
  35. GObjectPoolInterface.SetActive(false);
  36. AppBarPanel.OpenPanel(this);
  37. return base.GetFocus();
  38. }
  39. protected override void AddEvent()
  40. {
  41. EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  42. EventManager.Instance.AddEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);
  43. }
  44. private void CompleteUpdate(IEventData e)
  45. {
  46. UpdateContent();
  47. }
  48. public override CTask Show()
  49. {
  50. return base.Show();
  51. }
  52. protected override void DelEvent()
  53. {
  54. EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  55. EventManager.Instance.RemoveEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);
  56. }
  57. public override void AddButtonEvent()
  58. {
  59. Btn_Log.onClick.AddListener(() => { XianTuLogPanel.OpenPanel(); });
  60. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  61. Btn_ShenShi.onClick.AddListener(async () =>
  62. {
  63. if (saixuanType == 1)
  64. return;
  65. saixuanType = 1;
  66. UpdateContent();
  67. });
  68. Btn_DaoYou.onClick.AddListener(async () =>
  69. {
  70. if (saixuanType == 2)
  71. return;
  72. saixuanType = 2;
  73. UpdateContent();
  74. });
  75. }
  76. private void RemoveEvent(IEventData e)
  77. {
  78. // UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  79. // Content.Init(this, showEventList.Count);
  80. UpdateContent();
  81. }
  82. public async override CTask<bool> AsyncInit(object[] uiData)
  83. {
  84. await UpdateContent();
  85. return await base.AsyncInit(uiData);
  86. }
  87. private async CTask UpdateContent()
  88. {
  89. foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList)
  90. {
  91. UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2);
  92. }
  93. shengShiEventWidgetTypeList.Clear();
  94. //神识
  95. if (saixuanType == 1)
  96. {
  97. toggleList.ShowTargetIndex(0);
  98. TitleRoot.SetActive(true);
  99. Rect_Sv.SetParent(Sv1root);
  100. Rect_Sv.transform.SetAsFirstSibling();
  101. Rect_Sv.offsetMax =new Vector2(11.88f,0);
  102. Rect_Sv.offsetMin = Vector2.zero;
  103. // Rect_Sv.sizeDelta = new Vector2(718.82f, 844.7f);
  104. // Rect_Sv.anchoredPosition = new Vector2(2.61f, -190.52f);
  105. Text_Tips.gameObject.SetActive(false);
  106. AccountFileInfo.EventList eventList = EventSystemManager.Instance.GetMainEventDta();
  107. if (mainShengShiEventWidgetType2 == null)
  108. mainShengShiEventWidgetType2 =
  109. await UIManager.Instance.CreateGComponentForObject<ShengShiEventWidgetType2>(
  110. ShengShiEventWidgetType2Game, null, ShengShiEventWidgetType2Root);
  111. if (eventList != null)
  112. {
  113. mainShengShiEventWidgetType2.own.SetActive(true);
  114. mainShengShiEventWidgetType2.CustomInit(eventList, GoOnClick);
  115. mainShengShiEventWidgetType2.OnClick = OnClick;
  116. }
  117. else
  118. {
  119. mainShengShiEventWidgetType2.own.SetActive(true);
  120. mainShengShiEventWidgetType2.CustomInit1();
  121. }
  122. if (EventSystemManager.Instance.GetShenShiCount() > 0)
  123. {
  124. DivineSenceHuoQuWidgetGam.SetActive(false);
  125. }
  126. else
  127. {
  128. DivineSenceHuoQuWidgetGam.SetActive(true);
  129. DivineSenceHuoQuWidget shengShiEventWidgetType2 =
  130. await UIManager.Instance.CreateGComponentForObject<DivineSenceHuoQuWidget>(
  131. DivineSenceHuoQuWidgetGam, null);
  132. shengShiEventWidgetType2.OnClick = DivineSenceHuoQuWidgetOnClick;
  133. }
  134. }
  135. //道友
  136. else
  137. {
  138. toggleList.ShowTargetIndex(1);
  139. mainShengShiEventWidgetType2?.own.SetActive(false);
  140. // UIManager.Instance.DormancyGComponent(mainShengShiEventWidgetType2);
  141. // mainShengShiEventWidgetType2 = null;
  142. TitleRoot.SetActive(false);
  143. Rect_Sv.SetParent(Sv2root);
  144. Rect_Sv.offsetMax =new Vector2(11.88f,0);
  145. Rect_Sv.offsetMin = Vector2.zero;
  146. Text_Tips.gameObject.SetActive(showEventList.Count > 0);
  147. DivineSenceHuoQuWidgetGam.SetActive(false);
  148. }
  149. var divineSenseConfig =
  150. ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  151. int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax /
  152. PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  153. maxCount = maxCount > divineSenseConfig.MaxNum ? divineSenseConfig.MaxNum : maxCount;
  154. Text_ShenShiCount.text =
  155. LanguageManager.Instance.Text(10239, EventSystemManager.Instance.GetShenShiCount(), maxCount);
  156. SaiXuan(saixuanType);
  157. showEventList.Sort(Sort);
  158. creatCount = EventSystemManager.Instance.GetShenShiCount() > 0 && saixuanType == 1
  159. ? showEventList.Count + 1
  160. : showEventList.Count;
  161. await Content.Init(this, creatCount);
  162. }
  163. public int Sort(AccountFileInfo.EventList a, AccountFileInfo.EventList b)
  164. {
  165. if (a.isCompleted && !b.isCompleted)
  166. return 1;
  167. if (!a.isCompleted && b.isCompleted)
  168. return -1;
  169. return 0;
  170. }
  171. public void SaiXuan(int type)
  172. {
  173. showEventList.Clear();
  174. if (type == 1)
  175. {
  176. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  177. {
  178. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  179. if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4)
  180. {
  181. showEventList.Add(eventList);
  182. }
  183. }
  184. }
  185. else
  186. {
  187. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  188. {
  189. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  190. if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4)
  191. {
  192. showEventList.Add(eventList);
  193. }
  194. }
  195. }
  196. }
  197. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  198. {
  199. if (index < 0 || index >= creatCount)
  200. {
  201. return null;
  202. }
  203. if (index >= showEventList.Count && showEventList.Count != creatCount)
  204. {
  205. DivineSenceHuoQuWidget shengShiEventWidgetType2 =
  206. await UIManager.Instance.CreateGComponent<DivineSenceHuoQuWidget>(null, ContentRoot);
  207. shengShiEventWidgetType2.OnClick = DivineSenceHuoQuWidgetOnClick;
  208. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  209. return shengShiEventWidgetType2;
  210. }
  211. else
  212. {
  213. ShengShiEventWidgetType2 shengShiEventWidgetType2 =
  214. await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  215. shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick);
  216. shengShiEventWidgetType2.OnClick = OnClick;
  217. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  218. return shengShiEventWidgetType2;
  219. }
  220. }
  221. private void DivineSenceHuoQuWidgetOnClick(ItemWidgetBasic obj)
  222. {
  223. SkiptoHelper.Skipto(5);
  224. }
  225. private void GoOnClick(ItemWidgetBasic obj)
  226. {
  227. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  228. EventSystemManager.Instance.CancelEvent();
  229. if (EventSystemManager.Instance.isTriggerEvent)
  230. return;
  231. if (shengShiEventWidgetType2.eventList.isCompleted)
  232. {
  233. return;
  234. }
  235. EventConfig eventConfig =
  236. ConfigComponent.Instance.Get<EventConfig>(shengShiEventWidgetType2.eventList.eventID);
  237. if (eventConfig.EventTriggerType == 4)
  238. {
  239. if (shengShiEventWidgetType2.eventList.isCompleted1)
  240. {
  241. EventSystemManager.Instance.CompleteEvent(shengShiEventWidgetType2.eventList);
  242. // UpdateContent();
  243. return;
  244. }
  245. }
  246. isTriggerEvent = true;
  247. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  248. {
  249. isTriggerEvent = false;
  250. // UpdateContent();
  251. });
  252. }
  253. private void OnClick(ItemWidgetBasic obj)
  254. {
  255. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  256. //条件完成 任务没有完成 是最后一步就直接开始任务
  257. if (shengShiEventWidgetType2.isComplete && !shengShiEventWidgetType2.eventList.isCompleted)
  258. {
  259. if (shengShiEventWidgetType2.evenkConfig.ResultType == 0 ||
  260. shengShiEventWidgetType2.evenkConfig.ResultType == 3)
  261. {
  262. GoOnClick(shengShiEventWidgetType2);
  263. return;
  264. }
  265. }
  266. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList, 1);
  267. }
  268. public void HindIScorllListWidget(IScorllListWidget widget)
  269. {
  270. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  271. }
  272. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  273. {
  274. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  275. await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null, UILayer.Middle);
  276. return divineSenceEventPreviewPanel;
  277. }
  278. public async override CTask Close()
  279. {
  280. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  281. shengShiEventWidgetTypeList.Clear();
  282. EventSystemManager.Instance.isOpenUi = false;
  283. saixuanType = 1;
  284. mainShengShiEventWidgetType2?.DormancyObj();
  285. mainShengShiEventWidgetType2 = null;
  286. isTriggerEvent = false;
  287. await base.Close();
  288. }
  289. }
  290. }