DivineSenceEventPreviewPanel.cs 4.5 KB

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