XianTuLogInfoPanel.cs 8.9 KB

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