BigScreenLayer.cs 26 KB

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