DivineSenceEventPreviewPanel.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System.Collections.Generic;
  2. using Excel2Json;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. using UnityEngine;
  6. namespace Fort23.Mono
  7. {
  8. [UIBinding(prefab = "DivineSenceEventPreviewPanel")]
  9. public partial class DivineSenceEventPreviewPanel : UIPanel, IScrollListContent
  10. {
  11. public List<AccountFileInfo.EventList> showEventList = new List<AccountFileInfo.EventList>();
  12. List<ShengShiEventWidgetType2> shengShiEventWidgetTypeList = new List<ShengShiEventWidgetType2>();
  13. private ShengShiEventWidgetType2 mainShengShiEventWidgetType2;
  14. private int saixuanType = 1;
  15. bool isTriggerEvent = false;
  16. private void Init()
  17. {
  18. // isPopUi = true;
  19. isAddStack = true;
  20. IsShowAppBar = false;
  21. }
  22. protected override void AddEvent()
  23. {
  24. EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  25. }
  26. public override CTask GetFocus()
  27. {
  28. if (isTriggerEvent)
  29. GObjectPoolInterface.SetActive(false);
  30. return base.GetFocus();
  31. }
  32. public override CTask Show()
  33. {
  34. return base.Show();
  35. }
  36. protected override void DelEvent()
  37. {
  38. EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  39. }
  40. public override void AddButtonEvent()
  41. {
  42. Btn_Log.onClick.AddListener(() => { XianTuLogPanel.OpenPanel(); });
  43. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  44. Btn_ShenShi.onClick.AddListener(async () =>
  45. {
  46. if (saixuanType == 1)
  47. return;
  48. saixuanType = 1;
  49. UpdateContent();
  50. });
  51. Btn_DaoYou.onClick.AddListener(async () =>
  52. {
  53. if (saixuanType == 2)
  54. return;
  55. saixuanType = 2;
  56. UpdateContent();
  57. });
  58. }
  59. private void RemoveEvent(IEventData e)
  60. {
  61. // UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  62. // Content.Init(this, showEventList.Count);
  63. UpdateContent();
  64. }
  65. public async override CTask<bool> AsyncInit(object[] uiData)
  66. {
  67. await UpdateContent();
  68. return await base.AsyncInit(uiData);
  69. }
  70. private async CTask UpdateContent()
  71. {
  72. foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList)
  73. {
  74. UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2);
  75. }
  76. if (mainShengShiEventWidgetType2 == null)
  77. mainShengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ShengShiEventWidgetType2Root);
  78. AccountFileInfo.EventList eventList = EventSystemManager.Instance.GetMainEventDta();
  79. mainShengShiEventWidgetType2.CustomInit(eventList, GoOnClick);
  80. mainShengShiEventWidgetType2.OnClick = OnClick;
  81. shengShiEventWidgetTypeList.Clear();
  82. int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  83. Text_ShenShiCount.text = $"神识{EventSystemManager.Instance.GetShenShiCount()}/{maxCount}";
  84. SaiXuan(saixuanType);
  85. await Content.Init(this, showEventList.Count);
  86. }
  87. public void SaiXuan(int type)
  88. {
  89. showEventList.Clear();
  90. if (type == 1)
  91. {
  92. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  93. {
  94. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  95. if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4)
  96. {
  97. showEventList.Add(eventList);
  98. }
  99. }
  100. }
  101. else
  102. {
  103. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  104. {
  105. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  106. if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4)
  107. {
  108. showEventList.Add(eventList);
  109. }
  110. }
  111. }
  112. }
  113. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  114. {
  115. if (index < 0 || index >= showEventList.Count)
  116. {
  117. return null;
  118. }
  119. ShengShiEventWidgetType2 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  120. shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick);
  121. shengShiEventWidgetType2.OnClick = OnClick;
  122. shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2);
  123. return shengShiEventWidgetType2;
  124. }
  125. private void GoOnClick(ItemWidgetBasic obj)
  126. {
  127. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  128. EventSystemManager.Instance.CancelEvent();
  129. if (EventSystemManager.Instance.isTriggerEvent)
  130. return;
  131. isTriggerEvent = true;
  132. this.GObjectPoolInterface.SetActive(false);
  133. // EventSystemManager.Instance.isOpenUi = false;
  134. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  135. {
  136. this.GObjectPoolInterface.SetActive(true);
  137. isTriggerEvent = false;
  138. UpdateContent();
  139. });
  140. }
  141. private void OnClick(ItemWidgetBasic obj)
  142. {
  143. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  144. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList);
  145. }
  146. public void HindIScorllListWidget(IScorllListWidget widget)
  147. {
  148. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  149. }
  150. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  151. {
  152. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel = await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null);
  153. return divineSenceEventPreviewPanel;
  154. }
  155. public override void Close()
  156. {
  157. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  158. shengShiEventWidgetTypeList.Clear();
  159. EventSystemManager.Instance.isOpenUi = false;
  160. saixuanType = 1;
  161. mainShengShiEventWidgetType2 = null;
  162. isTriggerEvent = false;
  163. base.Close();
  164. }
  165. }
  166. }