XianTuLogInfoPanel.cs 12 KB

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