BigScreenLayer.cs 28 KB

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