XianTuLogInfoPanel.cs 14 KB

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