XianTuLogInfoPanel.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Core.Language;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using UnityEngine;
  8. using Utility;
  9. namespace Fort23.Mono
  10. {
  11. public class XianTuLogInfoData
  12. {
  13. /// <summary>
  14. /// 1.大标题 2.标题 3.描述
  15. /// </summary>
  16. public int type;
  17. public string message;
  18. }
  19. [UIBinding(prefab = "XianTuLogInfoPanel")]
  20. public partial class XianTuLogInfoPanel : UIPanel, IScrollListContent
  21. {
  22. private EventLogTitleWidget eventLogTitleWidget;
  23. private XianTuLogConfig _xianTuLogConfig;
  24. List<XianTuLogInfoData> showXianTuLogInfoData = new List<XianTuLogInfoData>();
  25. List<UIComponent> components = new List<UIComponent>();
  26. List<EventLogTitleWidget> titleWidgets = new List<EventLogTitleWidget>();
  27. private int type;
  28. private void Init()
  29. {
  30. }
  31. protected override void AddEvent()
  32. {
  33. }
  34. protected override void DelEvent()
  35. {
  36. }
  37. public override void AddButtonEvent()
  38. {
  39. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  40. }
  41. public async void CustomInit(int type, int id)
  42. {
  43. this.type = type;
  44. eventLogTitleWidget = await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidget, null);
  45. Map<int, List<EventConfig>> eventConfigMap = new Map<int, List<EventConfig>>();
  46. showXianTuLogInfoData.Clear();
  47. _xianTuLogConfig = ConfigComponent.Instance.Get<XianTuLogConfig>(id);
  48. var configs = EventSystemManager.Instance.eventConfigsMap[_xianTuLogConfig.ID];
  49. foreach (var @c in configs)
  50. {
  51. EventConfig eventConfig = c;
  52. if (!eventConfigMap.ContainsKey(eventConfig.placeID))
  53. {
  54. eventConfigMap.Add(eventConfig.placeID, new List<EventConfig>());
  55. }
  56. eventConfigMap[eventConfig.placeID].Add(eventConfig);
  57. }
  58. foreach (var keyValuePair in eventConfigMap)
  59. {
  60. if (type == 1)
  61. {
  62. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(keyValuePair.Key);
  63. XianTuLogInfoData xianTuLogInfoData3 = new XianTuLogInfoData();
  64. xianTuLogInfoData3.type = 1;
  65. xianTuLogInfoData3.message = LanguageManager.Instance.Text(placesConfig.placeName);
  66. showXianTuLogInfoData.Add(xianTuLogInfoData3);
  67. }
  68. foreach (var eventConfig in keyValuePair.Value)
  69. {
  70. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(cl => cl.eventID == eventConfig.ID);
  71. if (eventList == null)
  72. {
  73. //主线没有做不显示问好
  74. if (_xianTuLogConfig.EventType == 2)
  75. {
  76. XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
  77. xianTuLogInfoData.type = 2;
  78. xianTuLogInfoData.message = "????????";
  79. XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
  80. xianTuLogInfoData1.type = 3;
  81. xianTuLogInfoData1.message = "?????????????????????????????????";
  82. showXianTuLogInfoData.Add(xianTuLogInfoData);
  83. showXianTuLogInfoData.Add(xianTuLogInfoData1);
  84. }
  85. }
  86. else
  87. {
  88. XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
  89. xianTuLogInfoData.type = 2;
  90. xianTuLogInfoData.message = LanguageManager.Instance.Text(eventConfig.EventName);
  91. showXianTuLogInfoData.Add(xianTuLogInfoData);
  92. foreach (var eventListSelectEventLinkId in eventList.selectEventLinkIds)
  93. {
  94. EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(eventListSelectEventLinkId);
  95. if (eventLinkConfig.LanID != null)
  96. {
  97. foreach (var i in eventLinkConfig.LanID)
  98. {
  99. XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
  100. xianTuLogInfoData1.type = 3;
  101. if (eventLinkConfig.NPCID != 0)
  102. {
  103. xianTuLogInfoData1.message = $"<color=#A6A6A6>{LanguageManager.Instance.Text(i)}</color>";
  104. }
  105. else
  106. {
  107. xianTuLogInfoData1.message = $"<color=#867169>{LanguageManager.Instance.Text(i)}</color>";
  108. }
  109. showXianTuLogInfoData.Add(xianTuLogInfoData1);
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. if (type == 1)
  117. {
  118. // eventLogTitleWidget.SetActive(true);
  119. Sv.SetParent(Marsk1,false);
  120. eventLogTitleWidget.CustomInit(showXianTuLogInfoData[0].message);
  121. eventLogTitleWidget.own.SetActive(true);
  122. }
  123. else if (type == 2)
  124. {
  125. Sv.SetParent(Marsk2,false);
  126. eventLogTitleWidget.own.SetActive(false);
  127. }
  128. Content.Init(this, showXianTuLogInfoData.Count);
  129. }
  130. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  131. {
  132. if (index < 0 || index >= showXianTuLogInfoData.Count)
  133. {
  134. return null;
  135. }
  136. XianTuLogInfoData xianTuLogInfoData = showXianTuLogInfoData[index];
  137. if (xianTuLogInfoData.type == 1)
  138. {
  139. EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponent<EventLogTitleWidget>(null, ContentRoot);
  140. eventLogTitleWidget.CustomInit(xianTuLogInfoData.message);
  141. titleWidgets.Add(eventLogTitleWidget);
  142. components.Add(eventLogTitleWidget);
  143. return eventLogTitleWidget;
  144. }
  145. else if (xianTuLogInfoData.type == 2)
  146. {
  147. EventLogInfoWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogInfoWidget>(null, ContentRoot);
  148. eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
  149. components.Add(eventLogInfoWidget);
  150. return eventLogInfoWidget;
  151. }
  152. else if (xianTuLogInfoData.type == 3)
  153. {
  154. EventLogMessageWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogMessageWidget>(null, ContentRoot);
  155. eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
  156. components.Add(eventLogInfoWidget);
  157. return eventLogInfoWidget;
  158. }
  159. return null;
  160. }
  161. public void HindIScorllListWidget(IScorllListWidget widget)
  162. {
  163. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  164. if (components.Contains(widget as UIComponent))
  165. {
  166. components.Remove(widget as UIComponent);
  167. }
  168. if (titleWidgets.Contains(widget as EventLogTitleWidget))
  169. {
  170. titleWidgets.Remove(widget as EventLogTitleWidget);
  171. }
  172. }
  173. public override void Close()
  174. {
  175. showXianTuLogInfoData.Clear();
  176. foreach (var uiComponent in components)
  177. {
  178. UIManager.Instance.DormancyGComponent(uiComponent);
  179. }
  180. components.Clear();
  181. titleWidgets.Clear();
  182. base.Close();
  183. }
  184. [CustomMethod(CustomMethodType.Update)]
  185. public void Update()
  186. {
  187. if (type != 1)
  188. return;
  189. EventLogTitleWidget highestItem = null;
  190. float maxY = float.MinValue;
  191. foreach (var xianTuTitleWidget in titleWidgets)
  192. {
  193. float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
  194. if (itemY > maxY)
  195. {
  196. maxY = itemY;
  197. highestItem = xianTuTitleWidget;
  198. }
  199. }
  200. if (highestItem != null)
  201. {
  202. float outsideY = eventLogTitleWidget.own.transform.position.y;
  203. if (maxY > outsideY )
  204. {
  205. eventLogTitleWidget.CustomInit(highestItem.Text_Name.text);
  206. }
  207. }
  208. }
  209. public async static CTask OpenPanel(int type, int id)
  210. {
  211. XianTuLogInfoPanel xianTuLogInfoPanel = await UIManager.Instance.LoadAndOpenPanel<XianTuLogInfoPanel>(null);
  212. xianTuLogInfoPanel.CustomInit(type, id);
  213. }
  214. }
  215. }