DivineSenceEventPreviewPanel.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. SaiXuan(1);
  41. foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList)
  42. {
  43. UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2);
  44. }
  45. shengShiEventWidgetTypeList.Clear();
  46. await Content.Init(this, showEventList.Count);
  47. });
  48. Btn_DaoYou.onClick.AddListener(async () =>
  49. {
  50. if (saixuanType == 2)
  51. return;
  52. saixuanType = 2;
  53. SaiXuan(2);
  54. foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList)
  55. {
  56. UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2);
  57. }
  58. shengShiEventWidgetTypeList.Clear();
  59. await Content.Init(this, showEventList.Count);
  60. });
  61. }
  62. private void RemoveEvent(IEventData e)
  63. {
  64. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  65. Content.Init(this, showEventList.Count);
  66. }
  67. public async override CTask<bool> AsyncInit(object[] uiData)
  68. {
  69. AccountFileInfo.EventList eventList = EventSystemManager.Instance.GetMainEventDta();
  70. ShengShiEventWidgetType2 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ShengShiEventWidgetType2Root);
  71. shengShiEventWidgetType2.CustomInit(eventList, GoOnClick);
  72. shengShiEventWidgetType2.OnClick = OnClick;
  73. SaiXuan(1);
  74. await Content.Init(this, showEventList.Count);
  75. return await base.AsyncInit(uiData);
  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. EventSystemManager.Instance.isOpenUi = true;
  127. });
  128. }
  129. private void OnClick(ItemWidgetBasic obj)
  130. {
  131. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  132. TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList);
  133. }
  134. public void HindIScorllListWidget(IScorllListWidget widget)
  135. {
  136. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  137. }
  138. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  139. {
  140. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel = await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null);
  141. return divineSenceEventPreviewPanel;
  142. }
  143. public override void Close()
  144. {
  145. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  146. shengShiEventWidgetTypeList.Clear();
  147. EventSystemManager.Instance.isOpenUi = false;
  148. base.Close();
  149. }
  150. }
  151. }