DivineSenceEventPreviewPanel.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using Excel2Json;
  2. using Fort23.Core;
  3. using Fort23.UTool;
  4. using UnityEngine;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "DivineSenceEventPreviewPanel")]
  8. public partial class DivineSenceEventPreviewPanel : UIPanel, IScrollListContent
  9. {
  10. private void Init()
  11. {
  12. isPopUi = true;
  13. // isAddStack = true;
  14. // IsShowAppBar = false;
  15. }
  16. protected override void AddEvent()
  17. {
  18. EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  19. }
  20. public override CTask GetFocus()
  21. {
  22. return base.GetFocus();
  23. }
  24. protected override void DelEvent()
  25. {
  26. EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);
  27. }
  28. public override void AddButtonEvent()
  29. {
  30. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  31. }
  32. private void RemoveEvent(IEventData e)
  33. {
  34. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  35. Content.Init(this, AccountFileInfo.Instance.playerData.eventList.Count);
  36. }
  37. public override CTask<bool> AsyncInit(object[] uiData)
  38. {
  39. Content.Init(this, AccountFileInfo.Instance.playerData.eventList.Count);
  40. return base.AsyncInit(uiData);
  41. }
  42. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  43. {
  44. if (index < 0 || index >= AccountFileInfo.Instance.playerData.eventList.Count)
  45. {
  46. return null;
  47. }
  48. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(AccountFileInfo.Instance.playerData.eventList[index].eventID);
  49. if (eventConfig.EventType == 2)
  50. {
  51. ShengShiEventWidgetType3 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType3>(null, ContentRoot);
  52. shengShiEventWidgetType2.CustomInit(AccountFileInfo.Instance.playerData.eventList[index]);
  53. shengShiEventWidgetType2.OnClick = ShengShiEventWidgetType3OnClick;
  54. return shengShiEventWidgetType2;
  55. }
  56. else
  57. {
  58. ShengShiEventWidgetType2 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent<ShengShiEventWidgetType2>(null, ContentRoot);
  59. shengShiEventWidgetType2.CustomInit(AccountFileInfo.Instance.playerData.eventList[index]);
  60. shengShiEventWidgetType2.OnClick = OnClick;
  61. return shengShiEventWidgetType2;
  62. }
  63. }
  64. private void ShengShiEventWidgetType3OnClick(ItemWidgetBasic obj)
  65. {
  66. ShengShiEventWidgetType3 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType3;
  67. if (EventSystemManager.Instance.isTriggerEvent)
  68. return;
  69. this.GObjectPoolInterface.SetActive(false);
  70. EventSystemManager.Instance.isOpenUi = false;
  71. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  72. {
  73. Content.Init(this, AccountFileInfo.Instance.playerData.eventList.Count);
  74. this.GObjectPoolInterface.SetActive(true);
  75. EventSystemManager.Instance.isOpenUi = true;
  76. });
  77. }
  78. private void OnClick(ItemWidgetBasic obj)
  79. {
  80. ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2;
  81. if (EventSystemManager.Instance.isTriggerEvent)
  82. return;
  83. this.GObjectPoolInterface.SetActive(false);
  84. EventSystemManager.Instance.isOpenUi = false;
  85. EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () =>
  86. {
  87. Content.Init(this, AccountFileInfo.Instance.playerData.eventList.Count);
  88. this.GObjectPoolInterface.SetActive(true);
  89. EventSystemManager.Instance.isOpenUi = true;
  90. });
  91. }
  92. public void HindIScorllListWidget(IScorllListWidget widget)
  93. {
  94. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  95. }
  96. public async static CTask<DivineSenceEventPreviewPanel> OpenPanel()
  97. {
  98. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel = await UIManager.Instance.LoadAndOpenPanel<DivineSenceEventPreviewPanel>(null);
  99. return divineSenceEventPreviewPanel;
  100. }
  101. public override void Close()
  102. {
  103. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidgetType2>();
  104. EventSystemManager.Instance.isOpenUi = false;
  105. base.Close();
  106. }
  107. }
  108. }