using System.Collections.Generic; using Excel2Json; using Fort23.Core; using Fort23.UTool; using UnityEngine; namespace Fort23.Mono { [UIBinding(prefab = "DivineSenceEventPreviewPanel")] public partial class DivineSenceEventPreviewPanel : UIPanel, IScrollListContent { public List showEventList = new List(); List shengShiEventWidgetTypeList = new List(); private int saixuanType = 1; private void Init() { // isPopUi = true; isAddStack = true; IsShowAppBar = false; } protected override void AddEvent() { EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent); } public override CTask GetFocus() { return base.GetFocus(); } protected override void DelEvent() { EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent); } public override void AddButtonEvent() { Btn_Log.onClick.AddListener(() => { XianTuLogPanel.OpenPanel(); }); Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); }); Btn_ShenShi.onClick.AddListener(async () => { if (saixuanType == 1) return; saixuanType = 1; UpdateContent(); }); Btn_DaoYou.onClick.AddListener(async () => { if (saixuanType == 2) return; saixuanType = 2; UpdateContent(); }); } private void RemoveEvent(IEventData e) { // UIManager.Instance.DormancyAllGComponent(); // Content.Init(this, showEventList.Count); UpdateContent(); } public async override CTask AsyncInit(object[] uiData) { AccountFileInfo.EventList eventList = EventSystemManager.Instance.GetMainEventDta(); ShengShiEventWidgetType2 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent(null, ShengShiEventWidgetType2Root); shengShiEventWidgetType2.CustomInit(eventList, GoOnClick); shengShiEventWidgetType2.OnClick = OnClick; await UpdateContent(); return await base.AsyncInit(uiData); } private async CTask UpdateContent() { foreach (var shengShiEventWidgetType2 in shengShiEventWidgetTypeList) { UIManager.Instance.DormancyGComponent(shengShiEventWidgetType2); } shengShiEventWidgetTypeList.Clear(); int maxCount = PlayerManager.Instance.myHero.powerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount; Text_ShenShiCount.text = $"神识{EventSystemManager.Instance.GetShenShiCount()}/{maxCount}"; SaiXuan(saixuanType); await Content.Init(this, showEventList.Count); } public void SaiXuan(int type) { showEventList.Clear(); if (type == 1) { foreach (var eventList in AccountFileInfo.Instance.playerData.eventList) { EventConfig eventConfig = ConfigComponent.Instance.Get(eventList.eventID); if (eventConfig.EventTriggerType != 5 && eventConfig.EventTriggerType != 4) { showEventList.Add(eventList); } } } else { foreach (var eventList in AccountFileInfo.Instance.playerData.eventList) { EventConfig eventConfig = ConfigComponent.Instance.Get(eventList.eventID); if (eventConfig.EventTriggerType == 5 && eventConfig.EventTriggerType != 4) { showEventList.Add(eventList); } } } } public async CTask GetIScorllListWidget(int index, RectTransform root) { if (index < 0 || index >= showEventList.Count) { return null; } ShengShiEventWidgetType2 shengShiEventWidgetType2 = await UIManager.Instance.CreateGComponent(null, ContentRoot); shengShiEventWidgetType2.CustomInit(showEventList[index], GoOnClick); shengShiEventWidgetType2.OnClick = OnClick; shengShiEventWidgetTypeList.Add(shengShiEventWidgetType2); return shengShiEventWidgetType2; } private void GoOnClick(ItemWidgetBasic obj) { ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2; if (EventSystemManager.Instance.isTriggerEvent) return; this.GObjectPoolInterface.SetActive(false); EventSystemManager.Instance.isOpenUi = false; EventSystemManager.Instance.TriggerEvent(shengShiEventWidgetType2.eventList, () => { // Content.Init(this, showEventList.Count); this.GObjectPoolInterface.SetActive(true); UpdateContent(); // EventSystemManager.Instance.isOpenUi = true; }); } private void OnClick(ItemWidgetBasic obj) { ShengShiEventWidgetType2 shengShiEventWidgetType2 = obj as ShengShiEventWidgetType2; TaskInfoPanel.OpenPanel(shengShiEventWidgetType2.eventList); } public void HindIScorllListWidget(IScorllListWidget widget) { UIManager.Instance.DormancyGComponent(widget as UIComponent); } public async static CTask OpenPanel() { DivineSenceEventPreviewPanel divineSenceEventPreviewPanel = await UIManager.Instance.LoadAndOpenPanel(null); return divineSenceEventPreviewPanel; } public override void Close() { UIManager.Instance.DormancyAllGComponent(); shengShiEventWidgetTypeList.Clear(); EventSystemManager.Instance.isOpenUi = false; saixuanType = 1; base.Close(); } } }