XianTuLogPanel.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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 OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
  8. using UnityEngine;
  9. using Utility;
  10. namespace Fort23.Mono
  11. {
  12. public class XianTuData
  13. {
  14. public int type;
  15. public string name;
  16. public XianTuLogConfig xianTuLogConfig;
  17. public XianTuData fatherXianTuData;
  18. }
  19. [UIBinding(prefab = "XianTuLogPanel")]
  20. public partial class XianTuLogPanel : UIPanel, IScrollListContent
  21. {
  22. private int type = 0;
  23. private int bigMaoXaiXuan = 0;
  24. private int placesXaiXuan = 0;
  25. List<XianTuLogConfig> xianTuLogConfigs = new List<XianTuLogConfig>();
  26. List<XianTuLogConfig> shoeXianTuLogConfigs = new List<XianTuLogConfig>();
  27. List<XianTuSaiXuanWidget> bigMapXianTuSaiWidgets = new List<XianTuSaiXuanWidget>();
  28. List<XianTuSaiXuanWidget> placesXianTuSaiWidgets = new List<XianTuSaiXuanWidget>();
  29. List<XianTuData> xianTuDatas = new List<XianTuData>();
  30. List<int> places = new List<int>();
  31. private EventLogTitleWidget eventLogTitleWidget;
  32. Map<int, List<int>> xianTuMapConfigd = new Map<int, List<int>>();
  33. List<UIComponent> components = new List<UIComponent>();
  34. private void Init()
  35. {
  36. isAddStack = true;
  37. }
  38. public override CTask GetFocus()
  39. {
  40. AppBarPanel.OpenPanel(this);
  41. return base.GetFocus();
  42. }
  43. protected override void AddEvent()
  44. {
  45. }
  46. protected override void DelEvent()
  47. {
  48. }
  49. public override void AddButtonEvent()
  50. {
  51. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  52. Btn_Main.onClick.AddListener(() => { Btn_Main_OnClick(); });
  53. Btn_Event.onClick.AddListener(() => { Btn_Event_OnClick(); });
  54. Btn_XaiXuan.onClick.AddListener(() => { Btn_XaiXuanClose.gameObject.SetActive(true); });
  55. Btn_XaiXuanClose.onClick.AddListener(() => { Btn_XaiXuanClose.gameObject.SetActive(false); });
  56. }
  57. private void Btn_Main_OnClick()
  58. {
  59. if (this.type == 1)
  60. return;
  61. Sv.transform.SetParent(MarskRoot1, false);
  62. Sv.GetComponent<RectTransform>().anchoredPosition = new Vector2(-22.45268f, 90);
  63. eventLogTitleWidget.own.gameObject.SetActive(false);
  64. ChangeList.ShowTargetIndex(0);
  65. Btn_XaiXuanClose.gameObject.SetActive(false);
  66. Btn_XaiXuan.gameObject.SetActive(false);
  67. bigMaoXaiXuan = 0;
  68. placesXaiXuan = 0;
  69. places.Clear();
  70. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  71. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  72. UIManager.Instance.DormancyAllGComponent<EventLogTitleWidget>();
  73. type = 1;
  74. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  75. XaiXuanMap(shoeXianTuLogConfigs);
  76. Content.Init(this, xianTuDatas.Count);
  77. }
  78. private void Btn_Event_OnClick()
  79. {
  80. if (this.type == 2)
  81. return;
  82. Sv.transform.SetParent(MarskRoot, false);
  83. Sv.GetComponent<RectTransform>().anchoredPosition = new Vector2(-22.45268f, 38.7f);
  84. eventLogTitleWidget.own.gameObject.SetActive(true);
  85. ChangeList.ShowTargetIndex(1);
  86. Btn_XaiXuanClose.gameObject.SetActive(false);
  87. Btn_XaiXuan.gameObject.SetActive(true);
  88. bigMaoXaiXuan = 0;
  89. placesXaiXuan = 0;
  90. places.Clear();
  91. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  92. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  93. UIManager.Instance.DormancyAllGComponent<EventLogTitleWidget>();
  94. components.Clear();
  95. type = 2;
  96. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  97. XaiXuanMap(shoeXianTuLogConfigs);
  98. if (xianTuDatas.Count > 0)
  99. {
  100. eventLogTitleWidget.own.SetActive(true);
  101. eventLogTitleWidget.CustomInit(xianTuDatas[0].name);
  102. }
  103. else
  104. {
  105. eventLogTitleWidget.own.SetActive(false);
  106. }
  107. Content.Init(this, xianTuDatas.Count);
  108. }
  109. private void XaiXuanMap(List<XianTuLogConfig> configs)
  110. {
  111. xianTuDatas.Clear();
  112. // List<XianTuLogConfig> showConfigs = new List<XianTuLogConfig>();
  113. Map<int, List<XianTuLogConfig>> xiantuMap = new Map<int, List<XianTuLogConfig>>();
  114. //全部 不筛选
  115. if (bigMaoXaiXuan == 0)
  116. {
  117. if (type == 1)
  118. {
  119. foreach (var xianTuLogConfig in configs)
  120. {
  121. XianTuData xianTuData2 = new XianTuData();
  122. xianTuData2.type = 2;
  123. xianTuData2.xianTuLogConfig = xianTuLogConfig;
  124. xianTuDatas.Add(xianTuData2);
  125. }
  126. return;
  127. }
  128. else
  129. {
  130. foreach (var xianTuLogConfig in configs)
  131. {
  132. if (xianTuMapConfigd.ContainsKey(xianTuLogConfig.ID))
  133. {
  134. foreach (var i in xianTuMapConfigd[xianTuLogConfig.ID])
  135. {
  136. if (!xiantuMap.ContainsKey(i))
  137. {
  138. xiantuMap.Add(i, new List<XianTuLogConfig>());
  139. }
  140. xiantuMap[i].Add(xianTuLogConfig);
  141. }
  142. }
  143. }
  144. }
  145. }
  146. else
  147. {
  148. List<EventConfig> eventConfigs;
  149. foreach (var xianTuLogConfig in configs)
  150. {
  151. if (EventSystemManager.Instance.eventConfigsMap.ContainsKey(xianTuLogConfig.ID))
  152. {
  153. eventConfigs = EventSystemManager.Instance.eventConfigsMap[xianTuLogConfig.ID];
  154. foreach (var eventConfig in eventConfigs)
  155. {
  156. if (places.Contains(eventConfig.placeID))
  157. {
  158. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
  159. if (!xiantuMap.ContainsKey(placesConfig.bigMapID))
  160. {
  161. xiantuMap.Add(placesConfig.bigMapID, new List<XianTuLogConfig>());
  162. }
  163. xiantuMap[placesConfig.bigMapID].Add(xianTuLogConfig);
  164. break;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. foreach (var keyValuePair in xiantuMap)
  171. {
  172. XianTuData xianTuData = new XianTuData();
  173. xianTuData.type = 1;
  174. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(keyValuePair.Key);
  175. int count = 0;
  176. int allCount = 0;
  177. xianTuDatas.Add(xianTuData);
  178. foreach (var xianTuLogConfig in keyValuePair.Value)
  179. {
  180. if (EventSystemManager.Instance.eventConfigsMap.ContainsKey(xianTuLogConfig.ID))
  181. {
  182. var eventConfigs1 = EventSystemManager.Instance.eventConfigsMap[xianTuLogConfig.ID];
  183. foreach (var eventConfig in eventConfigs1)
  184. {
  185. if (places.Contains(eventConfig.placeID) || places.Count <= 0)
  186. {
  187. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(cl => cl.eventID == eventConfig.ID);
  188. if (eventList != null)
  189. {
  190. count++;
  191. }
  192. allCount++;
  193. }
  194. }
  195. }
  196. XianTuData xianTuData2 = new XianTuData();
  197. xianTuData2.type = 2;
  198. xianTuData2.xianTuLogConfig = xianTuLogConfig;
  199. xianTuData2.fatherXianTuData = xianTuData;
  200. xianTuDatas.Add(xianTuData2);
  201. }
  202. xianTuData.name = LanguageManager.Instance.Text(10225, LanguageManager.Instance.Text(bigMapConfig.mapName),count,allCount) ;
  203. }
  204. }
  205. public async override CTask<bool> AsyncInit(object[] uiData)
  206. {
  207. int selectType = (int)uiData[0];
  208. xianTuLogConfigs = ConfigComponent.Instance.GetAll<XianTuLogConfig>().ToList();
  209. List<EventConfig> eventConfigs = ConfigComponent.Instance.GetAll<EventConfig>().ToList();
  210. foreach (var xianTuLogConfig in xianTuLogConfigs)
  211. {
  212. List<EventConfig> configs = eventConfigs.Where(ec => ec.XiantuID == xianTuLogConfig.ID).ToList();
  213. foreach (var eventConfig in configs)
  214. {
  215. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
  216. if (!xianTuMapConfigd.ContainsKey(xianTuLogConfig.ID))
  217. {
  218. xianTuMapConfigd.Add(xianTuLogConfig.ID, new List<int>());
  219. }
  220. if (!xianTuMapConfigd[xianTuLogConfig.ID].Contains(placesConfig.bigMapID))
  221. {
  222. xianTuMapConfigd[xianTuLogConfig.ID].Add(placesConfig.bigMapID);
  223. }
  224. }
  225. }
  226. XianTuSaiXuanWidget xianTuSaiXuanWidget1 = await UIManager.Instance.CreateGComponentForObject<XianTuSaiXuanWidget>(XianTuSaiXuanWidget1, null);
  227. xianTuSaiXuanWidget1.CustomInit(1, 0);
  228. xianTuSaiXuanWidget1.OnClick = OnClick;
  229. xianTuSaiXuanWidget1 = await UIManager.Instance.CreateGComponentForObject<XianTuSaiXuanWidget>(XianTuSaiXuanWidget2, null);
  230. xianTuSaiXuanWidget1.CustomInit(2, 0);
  231. xianTuSaiXuanWidget1.OnClick = OnClick;
  232. BigMapConfig[] bigMapConfigs = ConfigComponent.Instance.GetAll<BigMapConfig>();
  233. // foreach (var bigMapConfig in bigMapConfigs)
  234. // {
  235. // XianTuSaiXuanWidget xianTuSaiXuanWidget = await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, BigMapConnect);
  236. // xianTuSaiXuanWidget.CustomInit(1, bigMapConfig.ID);
  237. // xianTuSaiXuanWidget.OnClick = OnClick;
  238. // bigMapXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  239. // }
  240. XianTuSaiXuanWidget xianTuSaiXuanWidget = await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, BigMapConnect);
  241. xianTuSaiXuanWidget.CustomInit(1, bigMapConfigs[0].ID);
  242. xianTuSaiXuanWidget.OnClick = OnClick;
  243. bigMapXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  244. eventLogTitleWidget = await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidgetGam, null);
  245. BigMapList.GetChildObj();
  246. BigMapList.ShowTargetIndex(0);
  247. if (selectType == 1)
  248. {
  249. Btn_Main_OnClick();
  250. }
  251. else
  252. {
  253. Btn_Event_OnClick();
  254. }
  255. return await base.AsyncInit(uiData);
  256. }
  257. private async void OnClick(ItemWidgetBasic obj)
  258. {
  259. XianTuSaiXuanWidget xianTuSaiXuanWidge = obj as XianTuSaiXuanWidget;
  260. if (xianTuSaiXuanWidge.type == 1)
  261. {
  262. bigMaoXaiXuan = xianTuSaiXuanWidge._bigMapConfig.ID;
  263. placesXaiXuan = 0;
  264. foreach (var placesXianTuSaiWidget in placesXianTuSaiWidgets)
  265. {
  266. UIManager.Instance.DormancyGComponent(placesXianTuSaiWidget);
  267. }
  268. placesXianTuSaiWidgets.Clear();
  269. if (bigMaoXaiXuan == 0)
  270. {
  271. PlacesRoot.gameObject.SetActive(false);
  272. BigMapList.ShowTargetIndex(0);
  273. }
  274. else
  275. {
  276. PlacesRoot.gameObject.SetActive(true);
  277. foreach (var place in xianTuSaiXuanWidge._bigMapConfig.places)
  278. {
  279. XianTuSaiXuanWidget xianTuSaiXuanWidget = await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, PlacesConnect);
  280. xianTuSaiXuanWidget.CustomInit(2, place);
  281. xianTuSaiXuanWidget.OnClick = OnClick;
  282. placesXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  283. }
  284. BigMapList.ClickWidget(xianTuSaiXuanWidge.own.GetComponent<UIToggleWidgetBasic>());
  285. PlacesRootList.GetChildObj();
  286. PlacesRootList.ShowTargetIndex(0);
  287. }
  288. }
  289. else if (xianTuSaiXuanWidge.type == 2)
  290. {
  291. placesXaiXuan = xianTuSaiXuanWidge._placesConfig.ID;
  292. if (placesXaiXuan == 0)
  293. {
  294. PlacesRootList.ShowTargetIndex(0);
  295. }
  296. else
  297. {
  298. PlacesRootList.ClickWidget(xianTuSaiXuanWidge.own.GetComponent<UIToggleWidgetBasic>());
  299. }
  300. }
  301. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(bigMaoXaiXuan);
  302. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(placesXaiXuan);
  303. places.Clear();
  304. if (bigMaoXaiXuan == 0)
  305. {
  306. }
  307. else if (bigMaoXaiXuan != 0 && placesXaiXuan == 0)
  308. {
  309. places.AddRange(bigMapConfig.places);
  310. }
  311. else if (bigMaoXaiXuan != 0 && placesXaiXuan != 0)
  312. {
  313. places.Add(placesConfig.ID);
  314. }
  315. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  316. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  317. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  318. XaiXuanMap(shoeXianTuLogConfigs);
  319. components.Clear();
  320. if (xianTuDatas.Count > 0)
  321. {
  322. eventLogTitleWidget.own.SetActive(true);
  323. eventLogTitleWidget.CustomInit(xianTuDatas[0].name);
  324. }
  325. else
  326. {
  327. eventLogTitleWidget.own.SetActive(false);
  328. }
  329. Content.Init(this, xianTuDatas.Count);
  330. }
  331. private List<XianTuLogConfig> GetTypeXiantuLogConfigs(int type)
  332. {
  333. List<XianTuLogConfig> xianTuLogConfiges = new List<XianTuLogConfig>();
  334. foreach (var xianTuLogConfig in xianTuLogConfigs)
  335. {
  336. if (xianTuLogConfig.EventType == type)
  337. {
  338. xianTuLogConfiges.Add(xianTuLogConfig);
  339. }
  340. }
  341. return xianTuLogConfiges;
  342. }
  343. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  344. {
  345. if (index < 0 || index >= xianTuDatas.Count)
  346. {
  347. return null;
  348. }
  349. if (type == 1)
  350. {
  351. MainEventLogWidget mainEventLogWidget = await UIManager.Instance.CreateGComponent<MainEventLogWidget>(null, Content.GetComponent<RectTransform>());
  352. mainEventLogWidget.CustomInit(xianTuDatas[index].xianTuLogConfig);
  353. return mainEventLogWidget;
  354. }
  355. else
  356. {
  357. XianTuData xianTuData = xianTuDatas[index];
  358. if (xianTuData.type == 1)
  359. {
  360. EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidgetGam,null, Content.GetComponent<RectTransform>(),isInstance:true);
  361. eventLogTitleWidget.CustomInit(xianTuData);
  362. components.Add(eventLogTitleWidget);
  363. // xianTuTitleWidgets.Add(eventLogTitleWidget);
  364. return eventLogTitleWidget;
  365. }
  366. else
  367. {
  368. EventLogWidget EventLogWidget = await UIManager.Instance.CreateGComponent<EventLogWidget>(null, Content.GetComponent<RectTransform>());
  369. await EventLogWidget.CustomInit(xianTuData, places);
  370. components.Add(EventLogWidget);
  371. return EventLogWidget;
  372. }
  373. }
  374. }
  375. public void HindIScorllListWidget(IScorllListWidget widget)
  376. {
  377. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  378. if (components.Contains(widget as UIComponent))
  379. {
  380. components.Remove(widget as EventLogTitleWidget);
  381. }
  382. }
  383. public async static CTask OpenPanel(int type = 1)
  384. {
  385. XianTuLogPanel xianTuLogPanel = await UIManager.Instance.LoadAndOpenPanel<XianTuLogPanel>(null,uiData:new object[]{type});
  386. }
  387. List<UIComponent> _components = new List<UIComponent>();
  388. private float maxY;
  389. private float minY;
  390. [CustomMethod(CustomMethodType.Update)]
  391. public void Update()
  392. {
  393. if (type != 2)
  394. return;
  395. UIComponent highestItem = null;
  396. maxY = float.MinValue;
  397. minY = float.MaxValue;
  398. _components.Clear();
  399. foreach (var xianTuTitleWidget in components)
  400. {
  401. float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
  402. if (itemY > eventLogTitleWidget.own.transform.position.y)
  403. {
  404. maxY = itemY;
  405. _components.Add(xianTuTitleWidget);
  406. }
  407. }
  408. foreach (var uiComponent in _components)
  409. {
  410. float itemY = uiComponent.own.transform.position.y; // 使用世界坐标的 Y 值
  411. if (itemY < minY)
  412. {
  413. minY = itemY;
  414. highestItem = uiComponent;
  415. }
  416. }
  417. if (highestItem != null)
  418. {
  419. float outsideY = eventLogTitleWidget.own.transform.position.y;
  420. if (maxY > outsideY)
  421. {
  422. XianTuData xianTuData = default;
  423. if (highestItem is EventLogTitleWidget)
  424. {
  425. EventLogTitleWidget eventLogTitleWidget = highestItem as EventLogTitleWidget;
  426. xianTuData = eventLogTitleWidget.xiantuData;
  427. }
  428. else if (highestItem is EventLogWidget)
  429. {
  430. EventLogWidget eventLogWidget = highestItem as EventLogWidget;
  431. xianTuData = eventLogWidget.XianTuData.fatherXianTuData;
  432. }
  433. eventLogTitleWidget.CustomInit(xianTuData.name);
  434. }
  435. }
  436. }
  437. public async override CTask Close()
  438. {
  439. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  440. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  441. UIManager.Instance.DormancyAllGComponent<EventLogTitleWidget>();
  442. components.Clear();
  443. type = 0;
  444. foreach (var bigMapXianTuSaiWidget in bigMapXianTuSaiWidgets)
  445. {
  446. UIManager.Instance.DormancyGComponent(bigMapXianTuSaiWidget);
  447. }
  448. bigMapXianTuSaiWidgets.Clear();
  449. foreach (var placesXianTuSaiWidget in placesXianTuSaiWidgets)
  450. {
  451. UIManager.Instance.DormancyGComponent(placesXianTuSaiWidget);
  452. }
  453. placesXianTuSaiWidgets.Clear();
  454. Btn_XaiXuanClose.gameObject.SetActive(false);
  455. Btn_XaiXuan.gameObject.SetActive(false);
  456. bigMaoXaiXuan = 0;
  457. placesXaiXuan = 0;
  458. places.Clear();
  459. await base.Close();
  460. }
  461. }
  462. }