XianTuLogInfoPanel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. public int id;
  19. }
  20. [UIBinding(prefab = "XianTuLogInfoPanel")]
  21. public partial class XianTuLogInfoPanel : UIPanel, IScrollListContent
  22. {
  23. private EventLogTitleWidget eventLogTitleWidget;
  24. private XianTuLogConfig _xianTuLogConfig;
  25. List<XianTuLogInfoData> showXianTuLogInfoData = new List<XianTuLogInfoData>();
  26. List<UIComponent> components = new List<UIComponent>();
  27. // List<EventLogTitleWidget> titleWidgets = new List<EventLogTitleWidget>();
  28. private int type;
  29. private void Init()
  30. {
  31. }
  32. protected override void AddEvent()
  33. {
  34. }
  35. protected override void DelEvent()
  36. {
  37. }
  38. public override void AddButtonEvent()
  39. {
  40. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  41. Sr.onValueChanged.AddListener(OnValueChanged);
  42. }
  43. private void OnValueChanged(Vector2 arg0)
  44. {
  45. UpdateTitleWidget();
  46. }
  47. public async override CTask<bool> AsyncInit(object[] uiData)
  48. {
  49. await CustomInit((int)uiData[0], (int)uiData[1]);
  50. return await base.AsyncInit(uiData);
  51. }
  52. public async CTask CustomInit(int type, int id)
  53. {
  54. this.type = type;
  55. eventLogTitleWidget = await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidget, null);
  56. Map<int, List<EventConfig>> eventConfigMap = new Map<int, List<EventConfig>>();
  57. showXianTuLogInfoData.Clear();
  58. _xianTuLogConfig = ConfigComponent.Instance.Get<XianTuLogConfig>(id);
  59. var configs = EventSystemManager.Instance.eventConfigsMap[_xianTuLogConfig.ID];
  60. foreach (var @c in configs)
  61. {
  62. EventConfig eventConfig = c;
  63. if (!eventConfigMap.ContainsKey(eventConfig.placeID))
  64. {
  65. eventConfigMap.Add(eventConfig.placeID, new List<EventConfig>());
  66. }
  67. eventConfigMap[eventConfig.placeID].Add(eventConfig);
  68. }
  69. foreach (var keyValuePair in eventConfigMap)
  70. {
  71. if (type == 1)
  72. {
  73. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(keyValuePair.Key);
  74. XianTuLogInfoData xianTuLogInfoData3 = new XianTuLogInfoData();
  75. xianTuLogInfoData3.type = 1;
  76. xianTuLogInfoData3.id = keyValuePair.Value[0].ID;
  77. xianTuLogInfoData3.message = LanguageManager.Instance.Text(placesConfig.placeName);
  78. showXianTuLogInfoData.Add(xianTuLogInfoData3);
  79. }
  80. foreach (var eventConfig in keyValuePair.Value)
  81. {
  82. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(cl => cl.eventID == eventConfig.ID);
  83. if (eventList == null)
  84. {
  85. //主线没有做不显示问好
  86. if (_xianTuLogConfig.EventType == 2)
  87. {
  88. XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
  89. xianTuLogInfoData.type = 2;
  90. xianTuLogInfoData.id = eventConfig.ID;
  91. xianTuLogInfoData.message = "????????";
  92. XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
  93. xianTuLogInfoData1.type = 3;
  94. xianTuLogInfoData1.id = eventConfig.ID;
  95. xianTuLogInfoData1.message = "?????????????????????????????????";
  96. showXianTuLogInfoData.Add(xianTuLogInfoData);
  97. showXianTuLogInfoData.Add(xianTuLogInfoData1);
  98. }
  99. }
  100. else
  101. {
  102. XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
  103. xianTuLogInfoData.type = 2;
  104. xianTuLogInfoData.id = eventConfig.ID;
  105. xianTuLogInfoData.message = LanguageManager.Instance.Text(eventConfig.EventName);
  106. showXianTuLogInfoData.Add(xianTuLogInfoData);
  107. foreach (var eventListSelectEventLinkId in eventList.selectEventLinkIds)
  108. {
  109. EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(eventListSelectEventLinkId);
  110. if (eventLinkConfig.LanID != null)
  111. {
  112. foreach (var i in eventLinkConfig.LanID)
  113. {
  114. XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
  115. xianTuLogInfoData1.type = 3;
  116. xianTuLogInfoData1.id = eventConfig.ID;
  117. if (eventLinkConfig.NPCID != 0)
  118. {
  119. xianTuLogInfoData1.message = $"<color=#A6A6A6>{LanguageManager.Instance.Text(i)}</color>";
  120. }
  121. else
  122. {
  123. xianTuLogInfoData1.message = $"<color=#867169>{LanguageManager.Instance.Text(i)}</color>";
  124. }
  125. showXianTuLogInfoData.Add(xianTuLogInfoData1);
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. if (type == 1)
  133. {
  134. // eventLogTitleWidget.SetActive(true);
  135. Sv.SetParent(Marsk1, false);
  136. eventLogTitleWidget.CustomInit(showXianTuLogInfoData[0].message);
  137. eventLogTitleWidget.own.SetActive(true);
  138. }
  139. else if (type == 2)
  140. {
  141. Sv.SetParent(Marsk2, false);
  142. eventLogTitleWidget.own.SetActive(false);
  143. }
  144. await Content.Init(this, showXianTuLogInfoData.Count);
  145. }
  146. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  147. {
  148. if (index < 0 || index >= showXianTuLogInfoData.Count)
  149. {
  150. return null;
  151. }
  152. XianTuLogInfoData xianTuLogInfoData = showXianTuLogInfoData[index];
  153. if (xianTuLogInfoData.type == 1)
  154. {
  155. EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponent<EventLogTitleWidget>(null, ContentRoot);
  156. eventLogTitleWidget.CustomInit(xianTuLogInfoData);
  157. // titleWidgets.Add(eventLogTitleWidget);
  158. components.Add(eventLogTitleWidget);
  159. return eventLogTitleWidget;
  160. }
  161. else if (xianTuLogInfoData.type == 2)
  162. {
  163. EventLogInfoWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogInfoWidget>(null, ContentRoot);
  164. eventLogInfoWidget.CustomInit(xianTuLogInfoData);
  165. components.Add(eventLogInfoWidget);
  166. return eventLogInfoWidget;
  167. }
  168. else if (xianTuLogInfoData.type == 3)
  169. {
  170. EventLogMessageWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogMessageWidget>(null, ContentRoot);
  171. eventLogInfoWidget.CustomInit(xianTuLogInfoData);
  172. components.Add(eventLogInfoWidget);
  173. return eventLogInfoWidget;
  174. }
  175. return null;
  176. }
  177. public void HindIScorllListWidget(IScorllListWidget widget)
  178. {
  179. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  180. if (components.Contains(widget as UIComponent))
  181. {
  182. components.Remove(widget as UIComponent);
  183. }
  184. // if (titleWidgets.Contains(widget as EventLogTitleWidget))
  185. // {
  186. // titleWidgets.Remove(widget as EventLogTitleWidget);
  187. // }
  188. }
  189. public override void Close()
  190. {
  191. showXianTuLogInfoData.Clear();
  192. foreach (var uiComponent in components)
  193. {
  194. UIManager.Instance.DormancyGComponent(uiComponent);
  195. }
  196. components.Clear();
  197. // titleWidgets.Clear();
  198. base.Close();
  199. }
  200. List<UIComponent> _components = new List<UIComponent>();
  201. private float maxY;
  202. private float minY;
  203. public void UpdateTitleWidget()
  204. {
  205. if (type != 1)
  206. return;
  207. UIComponent highestItem = null;
  208. maxY = float.MinValue;
  209. minY = float.MaxValue;
  210. _components.Clear();
  211. foreach (var xianTuTitleWidget in components)
  212. {
  213. float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
  214. if (itemY > eventLogTitleWidget.own.transform.position.y)
  215. {
  216. maxY = itemY;
  217. // highestItem = xianTuTitleWidget;
  218. _components.Add(xianTuTitleWidget);
  219. }
  220. }
  221. foreach (var uiComponent in _components)
  222. {
  223. float itemY = uiComponent.own.transform.position.y; // 使用世界坐标的 Y 值
  224. if (itemY < minY)
  225. {
  226. minY = itemY;
  227. highestItem = uiComponent;
  228. }
  229. }
  230. if (highestItem != null)
  231. {
  232. float outsideY = eventLogTitleWidget.own.transform.position.y;
  233. if (maxY > outsideY)
  234. {
  235. EventConfig eventConfig = default;
  236. if (highestItem is EventLogTitleWidget)
  237. {
  238. EventLogTitleWidget eventLogTitleWidget = highestItem as EventLogTitleWidget;
  239. eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
  240. }
  241. else if (highestItem is EventLogInfoWidget)
  242. {
  243. EventLogInfoWidget eventLogTitleWidget = highestItem as EventLogInfoWidget;
  244. eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
  245. }
  246. else if (highestItem is EventLogMessageWidget)
  247. {
  248. EventLogMessageWidget eventLogTitleWidget = highestItem as EventLogMessageWidget;
  249. eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
  250. }
  251. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
  252. eventLogTitleWidget.CustomInit(LanguageManager.Instance.Text(placesConfig.placeName));
  253. }
  254. }
  255. }
  256. public async static CTask OpenPanel(int type, int id)
  257. {
  258. XianTuLogInfoPanel xianTuLogInfoPanel = await UIManager.Instance.LoadAndOpenPanel<XianTuLogInfoPanel>(null, uiData: new object[] { type, id });
  259. // xianTuLogInfoPanel.CustomInit(type, id);
  260. }
  261. }
  262. }