BigScreenLayer.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  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. await new WaitUntil(() =>
  374. {
  375. return GlobalData.buYuanSensorData.data.Count>0&&GlobalData.taoKouSensorData.data.Count>0;
  376. });
  377. floodTexts[0].text = (GlobalData.floorGateData.BuYuanOperationalGates + GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  378. floodTexts[1].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates - GlobalData.floorGateData.BuYuanOperationalGates - GlobalData.floorGateData.TaoKouOperationalGates).ToString();
  379. floodTexts[2].text = (GlobalData.floorGateData.BuYuanTotalGates + GlobalData.floorGateData.TaoKouTotalGates).ToString();
  380. floodButton.onClick.AddListener(() =>
  381. {
  382. popWindow.gameObject.SetActive(true);
  383. });
  384. floodListExitBtn.onClick.AddListener(() =>
  385. {
  386. popWindow.gameObject.SetActive(false);
  387. });
  388. floodListBtns[0].onClick.AddListener(() =>
  389. {
  390. floodListBtns[0].GetComponent<Image>().sprite = sprites[0];
  391. floodListBtns[1].GetComponent<Image>().sprite = sprites[1];
  392. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(true);
  393. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(false);
  394. });
  395. floodListBtns[1].onClick.AddListener(() =>
  396. {
  397. floodListBtns[0].GetComponent<Image>().sprite = sprites[1];
  398. floodListBtns[1].GetComponent<Image>().sprite = sprites[0];
  399. floodLists[0].transform.parent.parent.parent.gameObject.SetActive(false);
  400. floodLists[1].transform.parent.parent.parent.gameObject.SetActive(true);
  401. });
  402. var buyuanData = GlobalData.buYuanSensorData.data;
  403. for (int i = 0; i < buyuanData.Count; i++)
  404. {
  405. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  406. floodGateDataObj.transform.SetParent(floodLists[0].transform);
  407. floodGateDataObj.transform.localScale = Vector3.one;
  408. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  409. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = buyuanData[i].gate_opening ? "开启" : "关闭";
  410. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  411. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  412. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = buyuanData[i].opening_degree*0.01 + "m";
  413. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = buyuanData[i].gate_breakdown ? "故障":"正常";
  414. }
  415. var taokouData = GlobalData.taoKouSensorData.data;
  416. for (int i = 0; i < taokouData.Count; i++)
  417. {
  418. GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  419. floodGateDataObj.transform.SetParent(floodLists[1].transform);
  420. floodGateDataObj.transform.localScale = Vector3.one;
  421. floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  422. floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = taokouData[i].gate_opening ? "开启" : "关闭";
  423. floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = "- m³/s";
  424. floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = "m";
  425. floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = taokouData[i].opening_degree*0.01 + "m";
  426. floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = taokouData[i].gate_breakdown ? "故障":"正常";
  427. }
  428. // for (int i = 0; i < GlobalData.floorGateData.BuYuan.FloodGates.Length; i++)
  429. // {
  430. // GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  431. // floodGateDataObj.transform.SetParent(floodLists[0].transform);
  432. // floodGateDataObj.transform.localScale = Vector3.one;
  433. // floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  434. // floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].IsOpen ? "开启" : "关闭";
  435. // floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentFlow + "m³/s";
  436. // floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.CurrentWaterLevel + "m";
  437. // floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.BuYuan.FloodGates[i].CurrentOpening + "°";
  438. // switch (GlobalData.floorGateData.BuYuan.FloodGates[i].Status)
  439. // {
  440. // case 0:
  441. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  442. // break;
  443. // case 1:
  444. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  445. // break;
  446. // }
  447. // }
  448. // for (int i = 0; i < GlobalData.floorGateData.TaoKou.FloodGates.Length; i++)
  449. // {
  450. // GameObject floodGateDataObj = Instantiate(floodDataPrefab);
  451. // floodGateDataObj.transform.SetParent(floodLists[1].transform);
  452. // floodGateDataObj.transform.localScale = Vector3.one;
  453. // floodGateDataObj.transform.GetChild(1).GetComponent<Text>().text = (i + 1).ToString("00") + "号闸门";
  454. // floodGateDataObj.transform.GetChild(7).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].IsOpen ? "开启" : "关闭";
  455. // floodGateDataObj.transform.GetChild(8).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentFlow + "m³/s";
  456. // floodGateDataObj.transform.GetChild(9).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.CurrentWaterLevel + "m";
  457. // floodGateDataObj.transform.GetChild(10).GetComponent<Text>().text = GlobalData.floorGateData.TaoKou.FloodGates[i].CurrentOpening + "°";
  458. // switch (GlobalData.floorGateData.TaoKou.FloodGates[i].Status)
  459. // {
  460. // case 0:
  461. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "故障";
  462. // break;
  463. // case 1:
  464. // floodGateDataObj.transform.GetChild(11).GetComponent<Text>().text = "正常";
  465. // break;
  466. // }
  467. // }
  468. List<double> doubles = new List<double>();
  469. doubles.Add(90);
  470. doubles.Add(100);
  471. floodRingChart.UpdateData(0, 0, doubles);
  472. }
  473. private async Task InitInspectionStatistics()
  474. {
  475. await new WaitUntil(() =>
  476. {
  477. return GlobalData.InspectionStat.Count > 0;
  478. });
  479. currentYunIndex = 0;
  480. yunValue1.text = GlobalData.InspectionStat[0].daily.operationStaffCount.ToString();
  481. yunValue2.text = GlobalData.InspectionStat[0].daily.inspectionTasksCount.ToString();
  482. yunValue3.text = GlobalData.InspectionStat[0].daily.inspectionKilometers.ToString();
  483. yunValue4.text = GlobalData.InspectionStat[0].daily.faultHazardCount.ToString();
  484. yunValue5.text = GlobalData.InspectionStat[0].daily.processedFaultCount.ToString();
  485. yunValue6.text = GlobalData.InspectionStat[0].daily.engineeringMaintenanceCount.ToString();
  486. yunDrop0.onValueChanged.AddListener((index) =>
  487. {
  488. currentYunIndex = index;
  489. SwitchStationStat(yunDrop1.value);
  490. });
  491. yunDrop1.onValueChanged.AddListener((index) =>
  492. {
  493. SwitchStationStat(index);
  494. });
  495. }
  496. void SwitchStationStat(int index)
  497. {
  498. switch (index)
  499. {
  500. case 0:
  501. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].daily.operationStaffCount.ToString();
  502. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionTasksCount.ToString();
  503. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].daily.inspectionKilometers.ToString();
  504. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].daily.faultHazardCount.ToString();
  505. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].daily.processedFaultCount.ToString();
  506. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].daily.engineeringMaintenanceCount.ToString();
  507. break;
  508. case 1:
  509. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].monthly.operationStaffCount.ToString();
  510. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionTasksCount.ToString();
  511. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].monthly.inspectionKilometers.ToString();
  512. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].monthly.faultHazardCount.ToString();
  513. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].monthly.processedFaultCount.ToString();
  514. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].monthly.engineeringMaintenanceCount.ToString();
  515. break;
  516. case 2:
  517. yunValue1.text = GlobalData.InspectionStat[currentYunIndex].yearly.operationStaffCount.ToString();
  518. yunValue2.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionTasksCount.ToString();
  519. yunValue3.text = GlobalData.InspectionStat[currentYunIndex].yearly.inspectionKilometers.ToString();
  520. yunValue4.text = GlobalData.InspectionStat[currentYunIndex].yearly.faultHazardCount.ToString();
  521. yunValue5.text = GlobalData.InspectionStat[currentYunIndex].yearly.processedFaultCount.ToString();
  522. yunValue6.text = GlobalData.InspectionStat[currentYunIndex].yearly.engineeringMaintenanceCount.ToString();
  523. break;
  524. }
  525. }
  526. private async Task InitLayerBtns()
  527. {
  528. await new WaitUntil(() =>
  529. {
  530. return GlobalData.layerUnitDatas.Count > 0;
  531. });
  532. layerBtns = new List<LayerBtn>();
  533. for (int i = 0; i < zTLayer.layerDatas.Length; i++)
  534. {
  535. LayerBtn layerBtn = Instantiate(zTLayer.layerBtnPrefab);
  536. layerBtn.SetUseful(false);
  537. int index = i;
  538. int num = 0;
  539. if (i == 0)
  540. {
  541. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  542. for (int j = 0; j < tempDatas.Count; j++)
  543. {
  544. if (tempDatas[j].special == "1")
  545. {
  546. int tempJ = j;
  547. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  548. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  549. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  550. secLayerBtn.btn.onClick.AddListener(() =>
  551. {
  552. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  553. miniMap.gameObject.SetActive(false);
  554. ChangeRightContent(tempJ);
  555. });
  556. num++;
  557. }
  558. }
  559. layerBtn.secContent.gameObject.SetActive(true);
  560. }
  561. else
  562. {
  563. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  564. for (int j = 0; j < tempDatas.Count; j++)
  565. {
  566. Debug.Log(zTLayer.layerDatas.Length);
  567. Debug.Log(i);
  568. if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID)
  569. {
  570. int tempJ = j;
  571. SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
  572. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  573. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  574. secLayerBtn.btn.onClick.AddListener(() =>
  575. {
  576. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  577. miniMap.gameObject.SetActive(false);
  578. ChangeRightContent(tempJ);
  579. });
  580. num++;
  581. }
  582. }
  583. }
  584. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  585. {
  586. for (int j = 0; j < layerBtns.Count; j++)
  587. {
  588. layerBtns[j].SetUseful(false);
  589. layerBtns[j].secContent.gameObject.SetActive(false);
  590. }
  591. layerBtns[index].SetUseful(true);
  592. layerBtns[index].secContent.gameObject.SetActive(true);
  593. });
  594. layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
  595. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  596. layerBtn.transform.localScale = Vector3.one;
  597. layerBtns.Add(layerBtn);
  598. }
  599. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  600. layerBtns[0].SetUseful(true);
  601. }
  602. void ChangeRightContent(int index)
  603. {
  604. rightContent.parent.gameObject.SetActive(true);
  605. for (int i = 0; i < rightContent.childCount; i++)
  606. {
  607. rightContent.GetChild(i).gameObject.SetActive(false);
  608. }
  609. rightContent.GetChild(index).gameObject.SetActive(true);
  610. }
  611. // Update is called once per frame
  612. void Update()
  613. {
  614. znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
  615. }
  616. public async Task InitObsItems()
  617. {
  618. await new WaitUntil(() =>
  619. {
  620. return GlobalData.obsDatas_by.Count > 0&& GlobalData.obsDatas_tk.Count>0;
  621. });
  622. for (int i = 0; i < obsItemList.Count; i++)
  623. {
  624. Destroy(obsItemList[i].gameObject);
  625. }
  626. obsItemList.Clear();
  627. var obsDatasBy = GlobalData.obsDatas_by;
  628. for (int i = 0; i < obsDatasBy.Count; i++)
  629. {
  630. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  631. tempObj.SetData(obsDatasBy[i]);
  632. tempObj._button.onClick.AddListener(() =>
  633. {
  634. ShowObsPanel(tempObj._data);
  635. });
  636. obsItemList.Add(tempObj);
  637. }
  638. var obsDatasTk = GlobalData.obsDatas_tk;
  639. for (int i = 0; i < obsDatasTk.Count; i++)
  640. {
  641. var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
  642. tempObj.SetData(obsDatasTk[i]);
  643. tempObj._button.onClick.AddListener(() =>
  644. {
  645. ShowObsPanel(tempObj._data);
  646. });
  647. obsItemList.Add(tempObj);
  648. }
  649. }
  650. public void SearchObsItem(string s_name)
  651. {
  652. if (s_name.Equals(""))
  653. {
  654. for (int i = 0; i < obsItemList.Count; i++)
  655. {
  656. obsItemList[i].gameObject.SetActive(true);
  657. }
  658. }
  659. else
  660. {
  661. for (int i = 0; i < obsItemList.Count; i++)
  662. {
  663. obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
  664. }
  665. }
  666. }
  667. public void ShowObsPanel(ObsData _data)
  668. {
  669. obsPlayerPanel.gameObject.SetActive(true);
  670. obsPlayerPanel.SetObsData(_data);
  671. obsPlayerPanel.SetTitle(_data.name);
  672. }
  673. }