DivineSenceEventPreviewPanel.cs 6.4 KB

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