XianTuLogPanel.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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 =
  159. ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
  160. if (!xiantuMap.ContainsKey(placesConfig.bigMapID))
  161. {
  162. xiantuMap.Add(placesConfig.bigMapID, new List<XianTuLogConfig>());
  163. }
  164. xiantuMap[placesConfig.bigMapID].Add(xianTuLogConfig);
  165. break;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. foreach (var keyValuePair in xiantuMap)
  172. {
  173. XianTuData xianTuData = new XianTuData();
  174. xianTuData.type = 1;
  175. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(keyValuePair.Key);
  176. int count = 0;
  177. int allCount = 0;
  178. xianTuDatas.Add(xianTuData);
  179. foreach (var xianTuLogConfig in keyValuePair.Value)
  180. {
  181. if (EventSystemManager.Instance.eventConfigsMap.ContainsKey(xianTuLogConfig.ID))
  182. {
  183. var eventConfigs1 = EventSystemManager.Instance.eventConfigsMap[xianTuLogConfig.ID];
  184. foreach (var eventConfig in eventConfigs1)
  185. {
  186. if (places.Contains(eventConfig.placeID) || places.Count <= 0)
  187. {
  188. AccountFileInfo.EventList eventList =
  189. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(cl =>
  190. cl.eventID == eventConfig.ID);
  191. if (eventList == null)
  192. {
  193. eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(cl =>
  194. cl.eventID == eventConfig.ID && cl.isCompleted);
  195. }
  196. if (eventList != null)
  197. {
  198. count++;
  199. }
  200. allCount++;
  201. }
  202. }
  203. }
  204. XianTuData xianTuData2 = new XianTuData();
  205. xianTuData2.type = 2;
  206. xianTuData2.xianTuLogConfig = xianTuLogConfig;
  207. xianTuData2.fatherXianTuData = xianTuData;
  208. xianTuDatas.Add(xianTuData2);
  209. }
  210. xianTuData.name = LanguageManager.Instance.Text(10225,
  211. LanguageManager.Instance.Text(bigMapConfig.mapName), count, allCount);
  212. }
  213. }
  214. public async override CTask<bool> AsyncInit(object[] uiData)
  215. {
  216. int selectType = (int)uiData[0];
  217. xianTuLogConfigs = ConfigComponent.Instance.GetAll<XianTuLogConfig>().ToList();
  218. List<EventConfig> eventConfigs = ConfigComponent.Instance.GetAll<EventConfig>().ToList();
  219. foreach (var xianTuLogConfig in xianTuLogConfigs)
  220. {
  221. List<EventConfig> configs = eventConfigs.Where(ec => ec.XiantuID == xianTuLogConfig.ID).ToList();
  222. foreach (var eventConfig in configs)
  223. {
  224. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
  225. if (!xianTuMapConfigd.ContainsKey(xianTuLogConfig.ID))
  226. {
  227. xianTuMapConfigd.Add(xianTuLogConfig.ID, new List<int>());
  228. }
  229. if (!xianTuMapConfigd[xianTuLogConfig.ID].Contains(placesConfig.bigMapID))
  230. {
  231. xianTuMapConfigd[xianTuLogConfig.ID].Add(placesConfig.bigMapID);
  232. }
  233. }
  234. }
  235. XianTuSaiXuanWidget xianTuSaiXuanWidget1 =
  236. await UIManager.Instance.CreateGComponentForObject<XianTuSaiXuanWidget>(XianTuSaiXuanWidget1, null);
  237. xianTuSaiXuanWidget1.CustomInit(1, 0);
  238. xianTuSaiXuanWidget1.OnClick = OnClick;
  239. xianTuSaiXuanWidget1 =
  240. await UIManager.Instance.CreateGComponentForObject<XianTuSaiXuanWidget>(XianTuSaiXuanWidget2, null);
  241. xianTuSaiXuanWidget1.CustomInit(2, 0);
  242. xianTuSaiXuanWidget1.OnClick = OnClick;
  243. BigMapConfig[] bigMapConfigs = ConfigComponent.Instance.GetAll<BigMapConfig>();
  244. // foreach (var bigMapConfig in bigMapConfigs)
  245. // {
  246. // XianTuSaiXuanWidget xianTuSaiXuanWidget = await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, BigMapConnect);
  247. // xianTuSaiXuanWidget.CustomInit(1, bigMapConfig.ID);
  248. // xianTuSaiXuanWidget.OnClick = OnClick;
  249. // bigMapXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  250. // }
  251. XianTuSaiXuanWidget xianTuSaiXuanWidget =
  252. await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, BigMapConnect);
  253. xianTuSaiXuanWidget.CustomInit(1, bigMapConfigs[0].ID);
  254. xianTuSaiXuanWidget.OnClick = OnClick;
  255. bigMapXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  256. eventLogTitleWidget =
  257. await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidgetGam, null);
  258. BigMapList.GetChildObj();
  259. BigMapList.ShowTargetIndex(0);
  260. if (selectType == 1)
  261. {
  262. Btn_Main_OnClick();
  263. }
  264. else
  265. {
  266. Btn_Event_OnClick();
  267. }
  268. return await base.AsyncInit(uiData);
  269. }
  270. private async void OnClick(ItemWidgetBasic obj)
  271. {
  272. XianTuSaiXuanWidget xianTuSaiXuanWidge = obj as XianTuSaiXuanWidget;
  273. if (xianTuSaiXuanWidge.type == 1)
  274. {
  275. bigMaoXaiXuan = xianTuSaiXuanWidge._bigMapConfig.ID;
  276. placesXaiXuan = 0;
  277. foreach (var placesXianTuSaiWidget in placesXianTuSaiWidgets)
  278. {
  279. UIManager.Instance.DormancyGComponent(placesXianTuSaiWidget);
  280. }
  281. placesXianTuSaiWidgets.Clear();
  282. if (bigMaoXaiXuan == 0)
  283. {
  284. PlacesRoot.gameObject.SetActive(false);
  285. BigMapList.ShowTargetIndex(0);
  286. }
  287. else
  288. {
  289. PlacesRoot.gameObject.SetActive(true);
  290. foreach (var place in xianTuSaiXuanWidge._bigMapConfig.places)
  291. {
  292. XianTuSaiXuanWidget xianTuSaiXuanWidget =
  293. await UIManager.Instance.CreateGComponent<XianTuSaiXuanWidget>(null, PlacesConnect);
  294. xianTuSaiXuanWidget.CustomInit(2, place);
  295. xianTuSaiXuanWidget.OnClick = OnClick;
  296. placesXianTuSaiWidgets.Add(xianTuSaiXuanWidget);
  297. }
  298. BigMapList.ClickWidget(xianTuSaiXuanWidge.own.GetComponent<UIToggleWidgetBasic>());
  299. PlacesRootList.GetChildObj();
  300. PlacesRootList.ShowTargetIndex(0);
  301. }
  302. }
  303. else if (xianTuSaiXuanWidge.type == 2)
  304. {
  305. placesXaiXuan = xianTuSaiXuanWidge._placesConfig.ID;
  306. if (placesXaiXuan == 0)
  307. {
  308. PlacesRootList.ShowTargetIndex(0);
  309. }
  310. else
  311. {
  312. PlacesRootList.ClickWidget(xianTuSaiXuanWidge.own.GetComponent<UIToggleWidgetBasic>());
  313. }
  314. }
  315. BigMapConfig bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(bigMaoXaiXuan);
  316. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(placesXaiXuan);
  317. places.Clear();
  318. if (bigMaoXaiXuan == 0)
  319. {
  320. }
  321. else if (bigMaoXaiXuan != 0 && placesXaiXuan == 0)
  322. {
  323. places.AddRange(bigMapConfig.places);
  324. }
  325. else if (bigMaoXaiXuan != 0 && placesXaiXuan != 0)
  326. {
  327. places.Add(placesConfig.ID);
  328. }
  329. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  330. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  331. shoeXianTuLogConfigs = GetTypeXiantuLogConfigs(type);
  332. XaiXuanMap(shoeXianTuLogConfigs);
  333. components.Clear();
  334. if (xianTuDatas.Count > 0)
  335. {
  336. eventLogTitleWidget.own.SetActive(true);
  337. eventLogTitleWidget.CustomInit(xianTuDatas[0].name);
  338. }
  339. else
  340. {
  341. eventLogTitleWidget.own.SetActive(false);
  342. }
  343. Content.Init(this, xianTuDatas.Count);
  344. }
  345. private List<XianTuLogConfig> GetTypeXiantuLogConfigs(int type)
  346. {
  347. List<XianTuLogConfig> xianTuLogConfiges = new List<XianTuLogConfig>();
  348. foreach (var xianTuLogConfig in xianTuLogConfigs)
  349. {
  350. if (xianTuLogConfig.EventType == type)
  351. {
  352. xianTuLogConfiges.Add(xianTuLogConfig);
  353. }
  354. }
  355. return xianTuLogConfiges;
  356. }
  357. public async CTask<IScorllListWidget> GetIScorllListWidget(int index, RectTransform root)
  358. {
  359. if (index < 0 || index >= xianTuDatas.Count)
  360. {
  361. return null;
  362. }
  363. if (type == 1)
  364. {
  365. MainEventLogWidget mainEventLogWidget =
  366. await UIManager.Instance.CreateGComponent<MainEventLogWidget>(null,
  367. Content.GetComponent<RectTransform>());
  368. mainEventLogWidget.CustomInit(xianTuDatas[index].xianTuLogConfig);
  369. return mainEventLogWidget;
  370. }
  371. else
  372. {
  373. XianTuData xianTuData = xianTuDatas[index];
  374. if (xianTuData.type == 1)
  375. {
  376. EventLogTitleWidget eventLogTitleWidget =
  377. await UIManager.Instance.CreateGComponentForObject<EventLogTitleWidget>(EventLogTitleWidgetGam,
  378. null, Content.GetComponent<RectTransform>(), isInstance: true);
  379. eventLogTitleWidget.CustomInit(xianTuData);
  380. components.Add(eventLogTitleWidget);
  381. // xianTuTitleWidgets.Add(eventLogTitleWidget);
  382. return eventLogTitleWidget;
  383. }
  384. else
  385. {
  386. EventLogWidget EventLogWidget =
  387. await UIManager.Instance.CreateGComponent<EventLogWidget>(null,
  388. Content.GetComponent<RectTransform>());
  389. await EventLogWidget.CustomInit(xianTuData, places);
  390. components.Add(EventLogWidget);
  391. return EventLogWidget;
  392. }
  393. }
  394. }
  395. public void HindIScorllListWidget(IScorllListWidget widget)
  396. {
  397. UIManager.Instance.DormancyGComponent(widget as UIComponent);
  398. if (components.Contains(widget as UIComponent))
  399. {
  400. components.Remove(widget as EventLogTitleWidget);
  401. }
  402. }
  403. public async static CTask OpenPanel(int type = 1)
  404. {
  405. XianTuLogPanel xianTuLogPanel =
  406. await UIManager.Instance.LoadAndOpenPanel<XianTuLogPanel>(null, uiData: new object[] { type });
  407. }
  408. List<UIComponent> _components = new List<UIComponent>();
  409. private float maxY;
  410. private float minY;
  411. [CustomMethod(CustomMethodType.Update)]
  412. public void Update()
  413. {
  414. if (type != 2)
  415. return;
  416. UIComponent highestItem = null;
  417. maxY = float.MinValue;
  418. minY = float.MaxValue;
  419. _components.Clear();
  420. foreach (var xianTuTitleWidget in components)
  421. {
  422. float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
  423. if (itemY > eventLogTitleWidget.own.transform.position.y)
  424. {
  425. maxY = itemY;
  426. _components.Add(xianTuTitleWidget);
  427. }
  428. }
  429. foreach (var uiComponent in _components)
  430. {
  431. float itemY = uiComponent.own.transform.position.y; // 使用世界坐标的 Y 值
  432. if (itemY < minY)
  433. {
  434. minY = itemY;
  435. highestItem = uiComponent;
  436. }
  437. }
  438. if (highestItem != null)
  439. {
  440. float outsideY = eventLogTitleWidget.own.transform.position.y;
  441. if (maxY > outsideY)
  442. {
  443. XianTuData xianTuData = default;
  444. if (highestItem is EventLogTitleWidget)
  445. {
  446. EventLogTitleWidget eventLogTitleWidget = highestItem as EventLogTitleWidget;
  447. xianTuData = eventLogTitleWidget.xiantuData;
  448. }
  449. else if (highestItem is EventLogWidget)
  450. {
  451. EventLogWidget eventLogWidget = highestItem as EventLogWidget;
  452. xianTuData = eventLogWidget.XianTuData.fatherXianTuData;
  453. }
  454. eventLogTitleWidget.CustomInit(xianTuData.name);
  455. }
  456. }
  457. }
  458. public async override CTask Close()
  459. {
  460. UIManager.Instance.DormancyAllGComponent<MainEventLogWidget>();
  461. UIManager.Instance.DormancyAllGComponent<EventLogWidget>();
  462. UIManager.Instance.DormancyAllGComponent<EventLogTitleWidget>();
  463. components.Clear();
  464. type = 0;
  465. foreach (var bigMapXianTuSaiWidget in bigMapXianTuSaiWidgets)
  466. {
  467. UIManager.Instance.DormancyGComponent(bigMapXianTuSaiWidget);
  468. }
  469. bigMapXianTuSaiWidgets.Clear();
  470. foreach (var placesXianTuSaiWidget in placesXianTuSaiWidgets)
  471. {
  472. UIManager.Instance.DormancyGComponent(placesXianTuSaiWidget);
  473. }
  474. placesXianTuSaiWidgets.Clear();
  475. Btn_XaiXuanClose.gameObject.SetActive(false);
  476. Btn_XaiXuan.gameObject.SetActive(false);
  477. bigMaoXaiXuan = 0;
  478. placesXaiXuan = 0;
  479. places.Clear();
  480. await base.Close();
  481. }
  482. }
  483. }