DivineSenceEventPreviewPanel.cs 6.5 KB

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