DivineSenceEventPreviewPanel.cs 6.6 KB

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