BigScreenLayer.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. using Newtonsoft.Json.Linq;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.Networking;
  8. using UnityEngine.Serialization;
  9. using UnityEngine.UI;
  10. using System.Threading.Tasks;
  11. using UnityAsync;
  12. using WaitUntil = UnityAsync.WaitUntil;
  13. using System.Reflection;
  14. using XCharts.Runtime;
  15. [System.Serializable]
  16. public class FloodGate
  17. {
  18. public int GateNumber;
  19. public bool IsOpen;
  20. public float CurrentFlow;
  21. public float CurrentOpening;
  22. public int Status; // 1 for operational, 0 for faulty
  23. public string updateTime;
  24. }
  25. [System.Serializable]
  26. public class FloodGateLocationData
  27. {
  28. public float CurrentWaterLevel;
  29. public FloodGate[] FloodGates;
  30. }
  31. [System.Serializable]
  32. public class FloodGateStatusData
  33. {
  34. public FloodGateLocationData BuYuan;
  35. public FloodGateLocationData TaoKou;
  36. public bool success = false;
  37. public int BuYuanTotalGates => BuYuan.FloodGates.Length;
  38. public int BuYuanOperationalGates => CountOperationalGates(BuYuan.FloodGates);
  39. public int TaoKouTotalGates => TaoKou.FloodGates.Length;
  40. public int TaoKouOperationalGates => CountOperationalGates(TaoKou.FloodGates);
  41. private int CountOperationalGates(FloodGate[] gates)
  42. {
  43. int count = 0;
  44. foreach (var gate in gates)
  45. {
  46. if (gate.Status == 1) count++;
  47. }
  48. return count;
  49. }
  50. }
  51. [System.Serializable]
  52. public class WeatherData
  53. {
  54. public float Temperature;
  55. public string Weather;
  56. }
  57. [System.Serializable]
  58. public class LocationWeatherData
  59. {
  60. public float CurrentWaterLevel;
  61. public float Rainfall;
  62. public float FloodDischarge;
  63. public WeatherData WeatherData;
  64. }
  65. [System.Serializable]
  66. public class StationInspection
  67. {
  68. public InspectionDaily daily;
  69. public InspectionDaily monthly;
  70. public InspectionDaily yearly;
  71. }
  72. [System.Serializable]
  73. public class InspectionDaily
  74. {
  75. public int operationStaffCount;
  76. public int inspectionTasksCount;
  77. public int inspectionKilometers;
  78. public int faultHazardCount;
  79. public int processedFaultCount;
  80. public int engineeringMaintenanceCount;
  81. }
  82. [System.Serializable]
  83. public class AlertData
  84. {
  85. public bool success = false;
  86. public Alerts alerts;
  87. }
  88. [System.Serializable]
  89. public class Alerts
  90. {
  91. public List<AlertDataEvent> warningEvents = new List<AlertDataEvent>();
  92. public List<AlertDataEvent> floodForecasts = new List<AlertDataEvent>();
  93. public List<AlertDataEvent> weatherForecasts = new List<AlertDataEvent>();
  94. public List<AlertDataEvent> threeLineWarnings = new List<AlertDataEvent>();
  95. }
  96. [System.Serializable]
  97. public class AlertDataEvent
  98. {
  99. public int id;
  100. public string title;
  101. public string location;
  102. public string time;
  103. }
  104. public class BigScreenLayer : MonoBehaviour
  105. {
  106. public VerticalLayoutGroup content;
  107. public RectTransform znz;
  108. public Button gkButton;
  109. public Button normalButton;
  110. public Button clearBtn;
  111. public Button exitBtn;
  112. public Button exitJJBtn;
  113. public Button ddysButton;
  114. public Button exit_ddysButton;
  115. public GameObject gk;
  116. public GameObject normal;
  117. public YZTLayer zTLayer;
  118. public RectTransform miniMap;
  119. public RectTransform rightContent;
  120. public RingChart floodRingChart;
  121. public Button floodButton;
  122. public Text[] floodTexts;
  123. public RectTransform popWindow;
  124. public GameObject floodDataPrefab;
  125. public Button[] floodListBtns;
  126. public GridLayoutGroup[] floodLists;
  127. public Button floodListExitBtn;
  128. public Text swValue1;
  129. public Text swValue2;
  130. public Text swValue3;
  131. public Text swValue4;
  132. public Text swValue5;
  133. public Dropdown swDrop0;
  134. public Text yunValue1;
  135. public Text yunValue2;
  136. public Text yunValue3;
  137. public Text yunValue4;
  138. public Text yunValue5;
  139. public Text yunValue6;
  140. public int currentYunIndex = 0;
  141. public Dropdown yunDrop0;
  142. public Dropdown yunDrop1;
  143. List<LayerBtn> layerBtns = new List<LayerBtn>();
  144. // Start is called before the first frame update
  145. public GameObject obsItemPrefab;
  146. private List<ObsItem> obsItemList = new List<ObsItem>();
  147. private Transform obsItemContent;
  148. public ObsPlayerPanel obsPlayerPanel;
  149. private InputField _obsSearchInputField;
  150. public GameObject WaterRangeCtrlPanel;
  151. public GameObject yjPrefab;
  152. public Button[] yjBtns;
  153. public GridLayoutGroup[] yjLayout;
  154. public Sprite[] sprites;
  155. async void Start()
  156. {
  157. CameraManager.SwitchCamera(0);
  158. StaticLod.instance.OnFoucusStatic(0);
  159. InitButton();
  160. obsPlayerPanel = this.transform.Find("ObsPlayerPanel").GetComponent<ObsPlayerPanel>();
  161. obsPlayerPanel.gameObject.SetActive(false);
  162. obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content");
  163. _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent<InputField>();
  164. _obsSearchInputField.onValueChanged.AddListener(SearchObsItem);
  165. InitFloodGateData();
  166. InitHydrologicalData();
  167. InitLayerBtns();
  168. InitObsItems();
  169. InitInspectionStatistics();
  170. InitAlert();
  171. }
  172. void InitButton()
  173. {
  174. normalButton.onClick.AddListener(() =>
  175. {
  176. normal.gameObject.SetActive(true);
  177. gk.gameObject.SetActive(false);
  178. });
  179. gkButton.onClick.AddListener(() =>
  180. {
  181. gk.gameObject.SetActive(true);
  182. miniMap.gameObject.SetActive(true);
  183. rightContent.parent.gameObject.SetActive(false);
  184. normal.gameObject.SetActive(false);
  185. });
  186. clearBtn.onClick.AddListener(() =>
  187. {
  188. normal.gameObject.SetActive(false);
  189. gk.gameObject.SetActive(false);
  190. exitBtn.gameObject.SetActive(true);
  191. normalButton.gameObject.SetActive(false);
  192. gkButton.gameObject.SetActive(false);
  193. clearBtn.gameObject.SetActive(false);
  194. ddysButton.gameObject.SetActive(false);
  195. });
  196. exitBtn.onClick.AddListener(() =>
  197. {
  198. normal.gameObject.SetActive(true);
  199. gk.gameObject.SetActive(false);
  200. exitBtn.gameObject.SetActive(false);
  201. normalButton.gameObject.SetActive(true);
  202. gkButton.gameObject.SetActive(true);
  203. clearBtn.gameObject.SetActive(true);
  204. ddysButton.gameObject.SetActive(true);
  205. });
  206. exitJJBtn.onClick.AddListener(() =>
  207. {
  208. normal.gameObject.SetActive(true);
  209. gk.gameObject.SetActive(false);
  210. });
  211. ddysButton.onClick.AddListener(() =>
  212. {
  213. StaticLod.instance.OnFoucusStatic(-1);
  214. normal.gameObject.SetActive(false);
  215. gk.gameObject.SetActive(false);
  216. normalButton.gameObject.SetActive(false);
  217. gkButton.gameObject.SetActive(false);
  218. clearBtn.gameObject.SetActive(false);
  219. WaterRangeCtrlPanel.SetActive(true);
  220. });
  221. exit_ddysButton.onClick.AddListener(() =>
  222. {
  223. StaticLod.instance.OnFoucusStatic(0);
  224. WaterRangeCtrlPanel.SetActive(false);
  225. normal.gameObject.SetActive(true);
  226. gk.gameObject.SetActive(false);
  227. exitBtn.gameObject.SetActive(false);
  228. normalButton.gameObject.SetActive(true);
  229. gkButton.gameObject.SetActive(true);
  230. clearBtn.gameObject.SetActive(true);
  231. ddysButton.gameObject.SetActive(true);
  232. });
  233. // public Button ddysButton;
  234. // public Button exit_ddysButton;
  235. }
  236. private async Task InitAlert()
  237. {
  238. await new WaitUntil(() =>
  239. {
  240. return GlobalData.alertData.success;
  241. });
  242. for (int i = 0; i < yjLayout.Length; i++)
  243. {
  244. yjLayout[i].transform.parent.parent.parent.gameObject.SetActive(false);
  245. }
  246. yjLayout[0].transform.parent.parent.parent.gameObject.SetActive(true);
  247. for (int i = 0; i < GlobalData.alertData.alerts.warningEvents.Count; i++)
  248. {
  249. GameObject obj = Instantiate(yjPrefab);
  250. obj.transform.SetParent(yjLayout[0].transform);
  251. obj.transform.localScale = Vector3.one;
  252. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].id.ToString();
  253. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].title.ToString();
  254. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].location.ToString();
  255. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.warningEvents[i].time.ToString();
  256. }
  257. for (int i = 0; i < GlobalData.alertData.alerts.floodForecasts.Count; i++)
  258. {
  259. GameObject obj = Instantiate(yjPrefab);
  260. obj.transform.SetParent(yjLayout[1].transform);
  261. obj.transform.localScale = Vector3.one;
  262. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].id.ToString();
  263. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].title.ToString();
  264. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].location.ToString();
  265. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.floodForecasts[i].time.ToString();
  266. }
  267. for (int i = 0; i < GlobalData.alertData.alerts.weatherForecasts.Count; i++)
  268. {
  269. GameObject obj = Instantiate(yjPrefab);
  270. obj.transform.SetParent(yjLayout[2].transform);
  271. obj.transform.localScale = Vector3.one;
  272. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].id.ToString();
  273. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].title.ToString();
  274. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].location.ToString();
  275. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.weatherForecasts[i].time.ToString();
  276. }
  277. for (int i = 0; i < GlobalData.alertData.alerts.threeLineWarnings.Count; i++)
  278. {
  279. GameObject obj = Instantiate(yjPrefab);
  280. obj.transform.SetParent(yjLayout[3].transform);
  281. obj.transform.localScale = Vector3.one;
  282. obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].id.ToString();
  283. obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].title.ToString();
  284. obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].location.ToString();
  285. obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.alertData.alerts.threeLineWarnings[i].time.ToString();
  286. }
  287. for (int i = 0; i < yjBtns.Length; i++)
  288. {
  289. int temp = i;
  290. yjBtns[i].onClick.AddListener(() =>
  291. {
  292. for (int j = 0; j < yjBtns.Length; j++)
  293. {
  294. yjBtns[j].transform.GetChild(0).GetComponent<Text>().color = Color.gray;
  295. }
  296. yjBtns[temp].transform.GetChild(0).GetComponent<Text>().color = Color.white;
  297. for (int j = 0; j < yjLayout.Length; j++)
  298. {
  299. yjLayout[j].transform.parent.parent.parent.gameObject.SetActive(false);
  300. }
  301. yjLayout[temp].transform.parent.parent.parent.gameObject.SetActive(true);
  302. });
  303. }
  304. }
  305. private async Task InitHydrologicalData()
  306. {
  307. await new WaitUntil(() =>
  308. {
  309. return GlobalData.locationWeatherData.Count > 0;
  310. });
  311. ChangeLocationWeatherData(0);
  312. swDrop0.onValueChanged.AddListener((index) =>
  313. {
  314. ChangeLocationWeatherData(index);
  315. });
  316. }
  317. private void ChangeLocationWeatherData(int index)
  318. {
  319. swValue1.text = GlobalData.locationWeatherData[index].CurrentWaterLevel.ToString();
  320. swValue2.text = GlobalData.locationWeatherData[index].Rainfall.ToString();
  321. swValue3.text = GlobalData.locationWeatherData[index].WeatherData.Temperature.ToString();
  322. swValue4.text = GlobalData.locationWeatherData[index].WeatherData.Weather.ToString();
  323. swValue5.text = GlobalData.locationWeatherData[index].FloodDischarge.ToString();
  324. }
  325. private async Task InitFloodGateData()
  326. {
  327. await new WaitUntil(() =>
  328. {
  329. return GlobalData.floorGateData.success;
  330. });
  331. floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  332. floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  333. floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString();
  334. floodButton.onClick.AddListener(() =>
  335. {
  336. popWindow.gameObject.SetActive(true);
  337. });
  338. floodListExitBtn.onClick.AddListener(() =>
  339. {
  340. popWindow.gameObject.SetActive(false);
  341. });
  342. floodListBtns[0].onClick.AddListener(() =>
  343. {
  344. floodListBtns[0].GetComponent<Image>().sprite = sprites[0];
  345. floodListBtns[1].GetComponent<Image>().sprite = sprites[1];
  346. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true);
  347. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false);
  348. });
  349. floodListBtns[1].onClick.AddListener(() =>
  350. {
  351. floodListBtns[0].GetComponent<Image>().sprite = sprites[1];
  352. floodListBtns[1].GetComponent<Image>().sprite = sprites[0];
  353. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false);
  354. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true);
  355. });
  356. for (int i = 0; i < GlobalData.floorGateData.BuYuan.FloodGates.Length; i++)
  357. {
  358. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  359. floodGateDataObj.transform.SetParent(floodLists[0].transform);
  360. floodGateDataObj.transform.localScale = Vector3.one;
  361. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  362. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].IsOpen ? "开启" : "关闭";
  363. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentFlow + "m³/s";
  364. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.CurrentWaterLevel + "m";
  365. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentOpening + "°";
  366. switch (GlobalData.floorGateData.BuYuan.FloodGates[i].Status)
  367. {
  368. case 0:
  369. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  370. break;
  371. case 1:
  372. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  373. break;
  374. }
  375. }
  376. for (int i = 0; i < GlobalData.floorGateData.TaoKou.FloodGates.Length; i++)
  377. {
  378. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  379. floodGateDataObj.transform.SetParent(floodLists[1].transform);
  380. floodGateDataObj.transform.localScale = Vector3.one;
  381. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  382. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].IsOpen ? "开启" : "关闭";
  383. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentFlow + "m³/s";
  384. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.CurrentWaterLevel + "m";
  385. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentOpening + "°";
  386. switch (GlobalData.floorGateData.TaoKou.FloodGates[i].Status)
  387. {
  388. case 0:
  389. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  390. break;
  391. case 1:
  392. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  393. break;
  394. }
  395. }
  396. List<double> doubles = new List<double>();
  397. doubles.Add(90);
  398. doubles.Add(100);
  399. floodRingChart.UpdateData(0, 0, doubles);
  400. }
  401. private async Task InitInspectionStatistics()
  402. {
  403. await new WaitUntil(() =>
  404. {
  405. return GlobalData.InspectionStat.Count > 0;
  406. });
  407. currentYunIndex = 0;
  408. yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString();
  409. yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString();
  410. yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString();
  411. yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString();
  412. yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString();
  413. yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString();
  414. yunDrop0.onValueChanged.AddListener((index) =>
  415. {
  416. currentYunIndex = index;
  417. SwitchStationStat(yunDrop1.value);
  418. });
  419. yunDrop1.onValueChanged.AddListener((index) =>
  420. {
  421. SwitchStationStat(index);
  422. });
  423. }
  424. void SwitchStationStat(int index)
  425. {
  426. switch (index)
  427. {
  428. case 0:
  429. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString();
  430. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString();
  431. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString();
  432. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString();
  433. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString();
  434. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString();
  435. break;
  436. case 1:
  437. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString();
  438. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString();
  439. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString();
  440. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString();
  441. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString();
  442. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString();
  443. break;
  444. case 2:
  445. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString();
  446. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString();
  447. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString();
  448. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString();
  449. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString();
  450. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString();
  451. break;
  452. }
  453. }
  454. private async Task InitLayerBtns()
  455. {
  456. await new WaitUntil(() =>
  457. {
  458. return GlobalData.layerUnitDatas.Count > 0;
  459. });
  460. layerBtns = new List<LayerBtn>();
  461. for (int i = 0; i < zTLayer.layerDatas.Length; i++)
  462. {
  463. LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab);
  464. layerBtn.SetUseful(false);
  465. int index = i;
  466. int num = 0;
  467. if (i == 0)
  468. {
  469. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  470. for (int j = 0; j < tempDatas.Count; j++)
  471. {
  472. if (tempDatas[j].special == "1")
  473. {
  474. int tempJ = j;
  475. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  476. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  477. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  478. secLayerBtn.btn.onClick.AddListener(() =>
  479. {
  480. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  481. miniMap.gameObject.SetActive(false);
  482. ChangeRightContent(tempJ);
  483. });
  484. num++;
  485. }
  486. }
  487. layerBtn.secContent.gameObject.SetActive(true);
  488. }
  489. else
  490. {
  491. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  492. for (int j = 0; j < tempDatas.Count; j++)
  493. {
  494. Debug.Log(zTLayer.layerDatas.Length);
  495. Debug.Log(i);
  496. if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID)
  497. {
  498. int tempJ = j;
  499. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  500. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  501. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  502. secLayerBtn.btn.onClick.AddListener(() =>
  503. {
  504. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  505. miniMap.gameObject.SetActive(false);
  506. ChangeRightContent(tempJ);
  507. });
  508. num++;
  509. }
  510. }
  511. }
  512. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  513. {
  514. for (int j = 0; j < layerBtns.Count; j++)
  515. {
  516. layerBtns[j].SetUseful(false);
  517. layerBtns[j].secContent.gameObject.SetActive(false);
  518. }
  519. layerBtns[index].SetUseful(true);
  520. layerBtns[index].secContent.gameObject.SetActive(true);
  521. });
  522. layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
  523. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  524. layerBtn.transform.localScale = Vector3.one;
  525. layerBtns.Add(layerBtn);
  526. }
  527. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  528. layerBtns[0].SetUseful(true);
  529. }
  530. void ChangeRightContent(int index)
  531. {
  532. rightContent.parent.gameObject.SetActive(true);
  533. for (int i = 0; i < rightContent.childCount; i++)
  534. {
  535. rightContent.GetChild(i).gameObject.SetActive(false);
  536. }
  537. rightContent.GetChild(index).gameObject.SetActive(true);
  538. }
  539. // Update is called once per frame
  540. void Update()
  541. {
  542. znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
  543. }
  544. public async Task InitObsItems()
  545. {
  546. await new WaitUntil(() =>
  547. {
  548. return GlobalData.obsDatas.Count > 0;
  549. });
  550. for (int i = 0; i < obsItemList.Count; i++)
  551. {
  552. Destroy(obsItemList[i].gameObject);
  553. }
  554. obsItemList.Clear();
  555. var obsDatas = GlobalData.obsDatas;
  556. for (int i = 0; i < obsDatas.Count; i++)
  557. {
  558. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  559. tempObj.SetData(obsDatas[i]);
  560. tempObj._button.onClick.AddListener(() =>
  561. {
  562. ShowObsPanel(tempObj._data);
  563. });
  564. obsItemList.Add(tempObj);
  565. }
  566. }
  567. public void SearchObsItem(string s_name)
  568. {
  569. if (s_name.Equals(""))
  570. {
  571. for (int i = 0; i < obsItemList.Count; i++)
  572. {
  573. obsItemList[i].gameObject.SetActive(true);
  574. }
  575. }
  576. else
  577. {
  578. for (int i = 0; i < obsItemList.Count; i++)
  579. {
  580. obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
  581. }
  582. }
  583. }
  584. public void ShowObsPanel(ObsData _data)
  585. {
  586. obsPlayerPanel.gameObject.SetActive(true);
  587. obsPlayerPanel.SetObsData(_data);
  588. }
  589. }