XianTuLogInfoPanel.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. xianTuLogInfoData1.message = LanguageManager.Instance.Text(i);
  102. showXianTuLogInfoData.Add(xianTuLogInfoData1);
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. if (type == 1)
  110. {
  111. // eventLogTitleWidget.SetActive(true);
  112. Sv.SetParent(Marsk1,false);
  113. eventLogTitleWidget.CustomInit(showXianTuLogInfoData[0].message);
  114. eventLogTitleWidget.own.SetActive(true);
  115. }
  116. else if (type == 2)
  117. {
  118. Sv.SetParent(Marsk2,false);
  119. eventLogTitleWidget.own.SetActive(false);
  120. }
  121. Content.Init(this, showXianTuLogInfoData.Count);
  122. }
  123. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  124. {
  125. if (index < 0 || index >= showXianTuLogInfoData.Count)
  126. {
  127. return null;
  128. }
  129. XianTuLogInfoData xianTuLogInfoData = showXianTuLogInfoData[index];
  130. if (xianTuLogInfoData.type == 1)
  131. {
  132. EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponent<EventLogTitleWidget>(null, ContentRoot);
  133. eventLogTitleWidget.CustomInit(xianTuLogInfoData.message);
  134. titleWidgets.Add(eventLogTitleWidget);
  135. components.Add(eventLogTitleWidget);
  136. return eventLogTitleWidget;
  137. }
  138. else if (xianTuLogInfoData.type == 2)
  139. {
  140. EventLogInfoWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogInfoWidget>(null, ContentRoot);
  141. eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
  142. components.Add(eventLogInfoWidget);
  143. return eventLogInfoWidget;
  144. }
  145. else if (xianTuLogInfoData.type == 3)
  146. {
  147. EventLogMessageWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogMessageWidget>(null, ContentRoot);
  148. eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
  149. components.Add(eventLogInfoWidget);
  150. return eventLogInfoWidget;
  151. }
  152. return null;
  153. }
  154. public void HindIScorllListWidget(IScorllListWidget widget)
  155. {
  156. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  157. if (components.Contains(widget as UIComponent))
  158. {
  159. components.Remove(widget as UIComponent);
  160. }
  161. if (titleWidgets.Contains(widget as EventLogTitleWidget))
  162. {
  163. titleWidgets.Remove(widget as EventLogTitleWidget);
  164. }
  165. }
  166. public override void Close()
  167. {
  168. showXianTuLogInfoData.Clear();
  169. foreach (var uiComponent in components)
  170. {
  171. UIManager.Instance.DormancyGComponent(uiComponent);
  172. }
  173. components.Clear();
  174. titleWidgets.Clear();
  175. base.Close();
  176. }
  177. [CustomMethod(CustomMethodType.Update)]
  178. public void Update()
  179. {
  180. if (type != 2)
  181. return;
  182. EventLogTitleWidget highestItem = null;
  183. float maxY = float.MinValue;
  184. foreach (var xianTuTitleWidget in titleWidgets)
  185. {
  186. float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
  187. if (itemY > maxY)
  188. {
  189. maxY = itemY;
  190. highestItem = xianTuTitleWidget;
  191. }
  192. }
  193. if (highestItem != null)
  194. {
  195. float outsideY = eventLogTitleWidget.own.transform.position.y;
  196. if (maxY > outsideY - 5)
  197. {
  198. eventLogTitleWidget.CustomInit(highestItem.Text_Name.text);
  199. }
  200. }
  201. }
  202. public async static CTask OpenPanel(int type, int id)
  203. {
  204. XianTuLogInfoPanel xianTuLogInfoPanel = await UIManager.Instance.LoadAndOpenPanel<XianTuLogInfoPanel>(null);
  205. xianTuLogInfoPanel.CustomInit(type, id);
  206. }
  207. }
  208. }