using System.Collections.Generic; using System.Linq; using Core.Language; using Excel2Json; using Fort23.Core; using Fort23.UTool; using UnityEngine; using Utility; namespace Fort23.Mono { public class XianTuLogInfoData { /// /// 1.大标题 2.标题 3.描述 /// public int type; public string message; } [UIBinding(prefab = "XianTuLogInfoPanel")] public partial class XianTuLogInfoPanel : UIPanel, IScrollListContent { private EventLogTitleWidget eventLogTitleWidget; private XianTuLogConfig _xianTuLogConfig; List showXianTuLogInfoData = new List(); List components = new List(); List titleWidgets = new List(); private int type; private void Init() { } protected override void AddEvent() { } protected override void DelEvent() { } public override void AddButtonEvent() { Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); }); } public async void CustomInit(int type, int id) { this.type = type; eventLogTitleWidget = await UIManager.Instance.CreateGComponentForObject(EventLogTitleWidget, null); Map> eventConfigMap = new Map>(); showXianTuLogInfoData.Clear(); _xianTuLogConfig = ConfigComponent.Instance.Get(id); var configs = EventSystemManager.Instance.eventConfigsMap[_xianTuLogConfig.ID]; foreach (var @c in configs) { EventConfig eventConfig = c; if (!eventConfigMap.ContainsKey(eventConfig.placeID)) { eventConfigMap.Add(eventConfig.placeID, new List()); } eventConfigMap[eventConfig.placeID].Add(eventConfig); } foreach (var keyValuePair in eventConfigMap) { if (type == 1) { PlacesConfig placesConfig = ConfigComponent.Instance.Get(keyValuePair.Key); XianTuLogInfoData xianTuLogInfoData3 = new XianTuLogInfoData(); xianTuLogInfoData3.type = 1; xianTuLogInfoData3.message = LanguageManager.Instance.Text(placesConfig.placeName); showXianTuLogInfoData.Add(xianTuLogInfoData3); } foreach (var eventConfig in keyValuePair.Value) { AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(cl => cl.eventID == eventConfig.ID); if (eventList == null) { //主线没有做不显示问好 if (_xianTuLogConfig.EventType == 2) { XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData(); xianTuLogInfoData.type = 2; xianTuLogInfoData.message = "????????"; XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData(); xianTuLogInfoData1.type = 3; xianTuLogInfoData1.message = "?????????????????????????????????"; showXianTuLogInfoData.Add(xianTuLogInfoData); showXianTuLogInfoData.Add(xianTuLogInfoData1); } } else { XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData(); xianTuLogInfoData.type = 2; xianTuLogInfoData.message = LanguageManager.Instance.Text(eventConfig.EventName); showXianTuLogInfoData.Add(xianTuLogInfoData); foreach (var eventListSelectEventLinkId in eventList.selectEventLinkIds) { EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get(eventListSelectEventLinkId); if (eventLinkConfig.LanID != null) { foreach (var i in eventLinkConfig.LanID) { XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData(); xianTuLogInfoData1.type = 3; if (eventLinkConfig.NPCID != 0) { xianTuLogInfoData1.message = $"{LanguageManager.Instance.Text(i)}"; } else { xianTuLogInfoData1.message = $"{LanguageManager.Instance.Text(i)}"; } showXianTuLogInfoData.Add(xianTuLogInfoData1); } } } } } } if (type == 1) { // eventLogTitleWidget.SetActive(true); Sv.SetParent(Marsk1,false); eventLogTitleWidget.CustomInit(showXianTuLogInfoData[0].message); eventLogTitleWidget.own.SetActive(true); } else if (type == 2) { Sv.SetParent(Marsk2,false); eventLogTitleWidget.own.SetActive(false); } Content.Init(this, showXianTuLogInfoData.Count); } public async CTask GetIScorllListWidget(int index, RectTransform root) { if (index < 0 || index >= showXianTuLogInfoData.Count) { return null; } XianTuLogInfoData xianTuLogInfoData = showXianTuLogInfoData[index]; if (xianTuLogInfoData.type == 1) { EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponent(null, ContentRoot); eventLogTitleWidget.CustomInit(xianTuLogInfoData.message); titleWidgets.Add(eventLogTitleWidget); components.Add(eventLogTitleWidget); return eventLogTitleWidget; } else if (xianTuLogInfoData.type == 2) { EventLogInfoWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent(null, ContentRoot); eventLogInfoWidget.CustomInit(xianTuLogInfoData.message); components.Add(eventLogInfoWidget); return eventLogInfoWidget; } else if (xianTuLogInfoData.type == 3) { EventLogMessageWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent(null, ContentRoot); eventLogInfoWidget.CustomInit(xianTuLogInfoData.message); components.Add(eventLogInfoWidget); return eventLogInfoWidget; } return null; } public void HindIScorllListWidget(IScorllListWidget widget) { UIManager.Instance.DormancyGComponent(widget as UIComponent); if (components.Contains(widget as UIComponent)) { components.Remove(widget as UIComponent); } if (titleWidgets.Contains(widget as EventLogTitleWidget)) { titleWidgets.Remove(widget as EventLogTitleWidget); } } public override void Close() { showXianTuLogInfoData.Clear(); foreach (var uiComponent in components) { UIManager.Instance.DormancyGComponent(uiComponent); } components.Clear(); titleWidgets.Clear(); base.Close(); } [CustomMethod(CustomMethodType.Update)] public void Update() { if (type != 2) return; EventLogTitleWidget highestItem = null; float maxY = float.MinValue; foreach (var xianTuTitleWidget in titleWidgets) { float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值 if (itemY > maxY) { maxY = itemY; highestItem = xianTuTitleWidget; } } if (highestItem != null) { float outsideY = eventLogTitleWidget.own.transform.position.y; if (maxY > outsideY - 5) { eventLogTitleWidget.CustomInit(highestItem.Text_Name.text); } } } public async static CTask OpenPanel(int type, int id) { XianTuLogInfoPanel xianTuLogInfoPanel = await UIManager.Instance.LoadAndOpenPanel(null); xianTuLogInfoPanel.CustomInit(type, id); } } }