YZTLayer.cs 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Threading.Tasks;
  7. using UnityEngine;
  8. using UnityEngine.Networking;
  9. using UnityEngine.UI;
  10. using UnityAsync;
  11. using WaitUntil = UnityAsync.WaitUntil;
  12. using DG.Tweening;
  13. using Unity.VisualScripting;
  14. using System.Reflection;
  15. using System.Linq;
  16. [System.Serializable]
  17. public class YZTLayerData
  18. {
  19. public string layerName;
  20. public int layerID;
  21. }
  22. public enum LayerUnitType
  23. {
  24. ZZ = 1,
  25. BZ,
  26. NC,
  27. QXZ,
  28. JK,
  29. QT
  30. }
  31. [System.Serializable]
  32. public class JKYJData
  33. {
  34. public int normal;
  35. public int total;
  36. public int fault;
  37. public List<JKYJChildData> items;
  38. }
  39. [System.Serializable]
  40. public class JKYJChildData
  41. {
  42. public string name;
  43. public string model;
  44. public string ipAddress;
  45. public string deviceId;
  46. public string channelId;
  47. public bool onlineStatus;
  48. }
  49. public class GCGKData
  50. {
  51. public string name;
  52. public string type;
  53. public int count;
  54. }
  55. [System.Serializable]
  56. public class LayerUnitData
  57. {
  58. public string special;
  59. public LayerUnitType type;
  60. public float longitude;
  61. public float latitude;
  62. public string name;
  63. public string namePri;
  64. public string text1;
  65. public string text2;
  66. public string GetTypeName()
  67. {
  68. string result = "";
  69. switch (type)
  70. {
  71. case LayerUnitType.ZZ:
  72. result = "闸站";
  73. break;
  74. case LayerUnitType.BZ:
  75. result = "泵站";
  76. break;
  77. case LayerUnitType.NC:
  78. result = "农场";
  79. break;
  80. case LayerUnitType.QXZ:
  81. result = "气象站";
  82. break;
  83. case LayerUnitType.JK:
  84. result = "监控";
  85. break;
  86. case LayerUnitType.QT:
  87. result = "其他";
  88. break;
  89. }
  90. return result;
  91. }
  92. }
  93. [System.Serializable]
  94. public class HotPointData
  95. {
  96. public LayerUnitType type;
  97. public float longitude;
  98. public float latitude;
  99. public string name;
  100. public string namePri;
  101. }
  102. [System.Serializable]
  103. public class SWStationRecordData
  104. {
  105. public string name;
  106. public string time;
  107. public string value;
  108. public int dir;
  109. public string stcd = "0";
  110. }
  111. public class YZTLayer : YZTRootLayer
  112. {
  113. public VerticalLayoutGroup content;
  114. public Sprite[] layerSprite;
  115. public Sprite[] hotPointSprite;
  116. public LayerBtn layerBtnPrefab;
  117. public SecLayerBtn secLayerBtnPrefab;
  118. public YZTLayerData[] layerDatas;
  119. public RectTransform leftContent;
  120. public RectTransform middleContent;
  121. public RectTransform rightContent;
  122. List<LayerBtn> layerBtns = new List<LayerBtn>();
  123. public RuntimePoint pointPrefab;
  124. public GameObject runtimePointObj;
  125. public RectTransform pointParent;
  126. List<RuntimePoint> runtimePointLib = new List<RuntimePoint>();
  127. public GameObject yZTMini;
  128. public GameObject yZT;
  129. public RectTransform infoRight;
  130. public Button returnBtn;
  131. private float clickInterval;
  132. private Vector3 startClickPosition;
  133. public Button[] leftButtons;
  134. public Button layerButton;
  135. public int currentActiveLeft = 0;
  136. public RectTransform layerInfo;
  137. public Button layerInfoExitBtn;
  138. public Button[] baseLayerInfoBtns;
  139. public Button[] layerInfoBtns;
  140. public List<int> cancelLayer = new List<int>();
  141. public Sprite[] sprites;
  142. public Text rainText;
  143. public Text[] rainTextNum;
  144. public GameObject thingPrefab;
  145. public RectTransform thingParent;
  146. public List<SWStationRecordData> rescordSWStationData = new List<SWStationRecordData>();
  147. public List<GameObject> thing3s = new List<GameObject>();
  148. public Button clearBtn;
  149. public RectTransform regionParent;
  150. public RectTransform[] riverLayerInfo;
  151. public RectTransform[] lakeLayerInfo;
  152. public GameObject regionObjParent;
  153. public GameObject regionObjParent2;
  154. public GameObject[] regionLayerObj;
  155. public GameObject[] riverLayerObj;
  156. public GameObject[] lakeLayerObj;
  157. public GameObject[] aqqLayerObj;
  158. public List<GameObject> region2LayerObj = new List<GameObject>();
  159. // Start is called before the first frame update
  160. public GameObject waterTrendPanelOri;
  161. public WaterTrendPanel _waterTrendPanel;
  162. public Item0 item0Prefab;
  163. public GameObject item0Parent;
  164. public Text normalCount;
  165. public Text badCount;
  166. public Text stopCount;
  167. public Text allCount;
  168. public Thing0 thing0Prefab;
  169. public RectTransform thing0Content;
  170. public Text totalJKNum;
  171. public Text normalJKNum;
  172. public Text errorJKNum;
  173. public Text currentSWText;
  174. public Text avgSWText;
  175. public Text sfSWText;
  176. public Text jjSWText;
  177. public Text bzSWText;
  178. async void Awake()
  179. {
  180. viewMode = ViewMode.miniMap;
  181. _waterTrendPanel = Instantiate(waterTrendPanelOri, this.transform).GetComponent<WaterTrendPanel>();
  182. _waterTrendPanel.Init();
  183. _waterTrendPanel.gameObject.SetActive(false);
  184. HideMain();
  185. await InitData();
  186. Init();
  187. InitLeftBtn();
  188. InitLayerInfo();
  189. InitLayerBtns();
  190. InitReturnBtn();
  191. InitGCGKData();
  192. InitJKYJData();
  193. InitSWYJData();
  194. InitRainInfo();
  195. InitSWHeightInfo();
  196. await InitPointData();
  197. InitPoint();
  198. }
  199. void HideMain()
  200. {
  201. clearBtn.GetComponent<Image>().sprite = sprites[1];
  202. leftContent.GetComponent<RectTransform>().anchoredPosition = new Vector2(-219.74f, 0);
  203. leftContent.GetComponent<CanvasGroup>().alpha = 0;
  204. pointParent.gameObject.SetActive(true);
  205. middleContent.GetComponent<RectTransform>().anchoredPosition = new Vector2(400f, 540);
  206. rightContent.GetComponent<RectTransform>().anchoredPosition = new Vector2(220.6f, 419.8932f);
  207. rightContent.GetComponent<CanvasGroup>().alpha = 0;
  208. clearBtn.GetComponent<RectTransform>().anchoredPosition = new Vector2(-827f, clearBtn.GetComponent<RectTransform>().anchoredPosition.y);
  209. }
  210. async void InitGCGKData()
  211. {
  212. //await new WaitUntil(() =>
  213. //{
  214. // return GlobalData.gcgkContents.Count > 2;
  215. //});
  216. //normalCount.text = GlobalData.gcgkContents[0].count.ToString() + "个";
  217. //badCount.text = GlobalData.gcgkContents[1].count.ToString() + "个";
  218. //stopCount.text = GlobalData.gcgkContents[2].count.ToString() + "个";
  219. //allCount.text = (GlobalData.gcgkContents[0].count + GlobalData.gcgkContents[1].count + GlobalData.gcgkContents[2].count).ToString() + "个";
  220. }
  221. async void InitJKYJData()
  222. {
  223. // Debug.Log("111");
  224. await new WaitUntil(() =>
  225. {
  226. return GlobalData.byJKYJContents.total > 0 && GlobalData.tkJKYJContents.total > 0;
  227. });
  228. //Debug.Log("222");
  229. for (int i = 0; i < GlobalData.byJKYJContents.items.Count; i++)
  230. {
  231. Thing0 thing0 = Instantiate(thing0Prefab);
  232. thing0.transform.SetParent(thing0Content);
  233. thing0.transform.localPosition = Vector3.zero;
  234. thing0.transform.localScale = Vector3.one;
  235. thing0.SetData(i.ToString(), GlobalData.byJKYJContents.items[i].name, "补元", "开启", GlobalData.byJKYJContents.items[i].onlineStatus ? "正常" : "故障");
  236. }
  237. //Debug.Log("333");
  238. for (int i = 0; i < GlobalData.tkJKYJContents.items.Count; i++)
  239. {
  240. Thing0 thing0 = Instantiate(thing0Prefab);
  241. thing0.transform.SetParent(thing0Content);
  242. thing0.transform.localPosition = Vector3.zero;
  243. thing0.transform.localScale = Vector3.one;
  244. thing0.SetData((i + GlobalData.byJKYJContents.total).ToString(), GlobalData.tkJKYJContents.items[i].name, "套口", "开启", GlobalData.tkJKYJContents.items[i].onlineStatus ? "正常" : "故障");
  245. }
  246. // Debug.Log("444");
  247. totalJKNum.text = (GlobalData.byJKYJContents.total + GlobalData.tkJKYJContents.total).ToString();
  248. normalJKNum.text = (GlobalData.byJKYJContents.normal + GlobalData.tkJKYJContents.normal).ToString();
  249. errorJKNum.text = (GlobalData.byJKYJContents.fault + GlobalData.tkJKYJContents.fault).ToString();
  250. }
  251. async void InitSWYJData()
  252. {
  253. //Debug.Log("555");
  254. await new WaitUntil(() =>
  255. {
  256. return GlobalData.swDatas.Count > 1;
  257. //return GlobalData.TaoKouShuiWeiDataList.Count > 1;
  258. });
  259. //Debug.Log("666");
  260. //float value1 = GlobalData.TaoKouShuiWeiDataList[0].value;
  261. //float value2 = GlobalData.TaoKouShuiWeiDataList[1].value;
  262. //if (value1 > 1000)
  263. //{
  264. // value1 = value1 / 100.0f;
  265. //}
  266. //if (value2 > 1000)
  267. //{
  268. // value2 = value2 / 100.0f;
  269. //}
  270. int index1 = FindIndexByHotPointName("套口(闸上)");
  271. int index2 = FindIndexByHotPointName("套口(闸下)");
  272. string value1 = GlobalData.swDatas[index1].upz ;
  273. string value2 = GlobalData.swDatas[index1].dwz;
  274. float avgValue = 0f;
  275. bool hasNumber1 = float.TryParse(value1, out float num1);
  276. bool hasNumber2 = float.TryParse(value2, out float num2);
  277. if (value1 == "-" && value2 == "-")
  278. {
  279. avgSWText.text = "-";
  280. }
  281. else if (hasNumber1 && hasNumber2)
  282. {
  283. avgValue = (num1 + num2) / 2;
  284. avgSWText.text = avgValue.ToString("0.00");
  285. }
  286. else if (hasNumber1)
  287. {
  288. avgSWText.text = num1.ToString("0.00");
  289. }
  290. else if (hasNumber2)
  291. {
  292. avgSWText.text = num2.ToString("0.00");
  293. }
  294. sfSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].floodProtectionLevel}";
  295. jjSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].warningLevel}";
  296. bzSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].guaranteeLevel}";
  297. currentSWText.text = value1;
  298. }
  299. void InitLeftBtn()
  300. {
  301. for (int i = 0; i < leftButtons.Length; i++)
  302. {
  303. int temp = i;
  304. leftButtons[i].onClick.AddListener(() =>
  305. {
  306. LeftBtnClick(temp);
  307. });
  308. }
  309. LeftBtnClick(0);
  310. clearBtn.onClick.AddListener(() =>
  311. {
  312. if (clearBtn.GetComponent<Image>().sprite == sprites[0])
  313. {
  314. for (int i = 0; i < leftButtons.Length; i++)
  315. leftButtons[i].gameObject.SetActive(false);
  316. clearBtn.GetComponent<Image>().sprite = sprites[1];
  317. DOTween.To(() => leftContent.GetComponent<RectTransform>().anchoredPosition, x => leftContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(-219.74f, 0), 0.3f);
  318. DOTween.To(() => leftContent.GetComponent<CanvasGroup>().alpha, x => leftContent.GetComponent<CanvasGroup>().alpha = x, 0, 0.3f);
  319. pointParent.gameObject.SetActive(true);
  320. DOTween.To(() => middleContent.GetComponent<RectTransform>().anchoredPosition, x => middleContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(400f, 540), 0.3f);
  321. DOTween.To(() => rightContent.GetComponent<RectTransform>().anchoredPosition, x => rightContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(220.6f, 419.8932f), 0.3f);
  322. DOTween.To(() => rightContent.GetComponent<CanvasGroup>().alpha, x => rightContent.GetComponent<CanvasGroup>().alpha = x, 0, 0.3f);
  323. clearBtn.GetComponent<RectTransform>().DOLocalMoveX(-827f, 0.3f);
  324. }
  325. else
  326. {
  327. for (int i = 0; i < leftButtons.Length; i++)
  328. leftButtons[i].gameObject.SetActive(true);
  329. clearBtn.GetComponent<Image>().sprite = sprites[0];
  330. DOTween.To(() => leftContent.GetComponent<RectTransform>().anchoredPosition, x => leftContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(219.74f, 0), 0.3f);
  331. DOTween.To(() => leftContent.GetComponent<CanvasGroup>().alpha, x => leftContent.GetComponent<CanvasGroup>().alpha = x, 1, 0.3f);
  332. pointParent.gameObject.SetActive(true);
  333. DOTween.To(() => middleContent.GetComponent<RectTransform>().anchoredPosition, x => middleContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(0f, 540), 0.3f);
  334. DOTween.To(() => rightContent.GetComponent<RectTransform>().anchoredPosition, x => rightContent.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(-220.6f, 419.8932f), 0.3f);
  335. DOTween.To(() => rightContent.GetComponent<CanvasGroup>().alpha, x => rightContent.GetComponent<CanvasGroup>().alpha = x, 1, 0.3f);
  336. clearBtn.GetComponent<RectTransform>().DOLocalMoveX(-457f, 0.3f);
  337. }
  338. });
  339. for (int i = 0; i < leftButtons.Length; i++)
  340. leftButtons[i].gameObject.SetActive(false);
  341. }
  342. async void InitSWHeightInfo()
  343. {
  344. await new WaitUntil(() =>
  345. {
  346. return GlobalData.swDatas.Count > 0;
  347. });
  348. if (rescordSWStationData.Count < 1)
  349. {
  350. for (int i = 0; i < GlobalData.swDatas.Count; i++)
  351. {
  352. SWStationRecordData sWStationRecordData = new SWStationRecordData();
  353. sWStationRecordData.dir = 0;
  354. sWStationRecordData.name = GlobalData.swDatas[i].stnm;
  355. float valueUpz = GlobalData.swDatas[i].upz == "-" ? float.MinValue : float.Parse(GlobalData.swDatas[i].upz);
  356. float valueDwz = GlobalData.swDatas[i].dwz == "-" ? float.MinValue : float.Parse(GlobalData.swDatas[i].dwz);
  357. if (valueUpz == float.MinValue && valueDwz == float.MinValue)
  358. {
  359. sWStationRecordData.value = "-";
  360. }
  361. else if (valueUpz == float.MinValue)
  362. {
  363. sWStationRecordData.value = GlobalData.swDatas[i].dwz;
  364. }
  365. else if (valueDwz == float.MinValue)
  366. {
  367. sWStationRecordData.value = GlobalData.swDatas[i].upz;
  368. }
  369. else
  370. {
  371. sWStationRecordData.value = (valueUpz > valueDwz) ? GlobalData.swDatas[i].upz : GlobalData.swDatas[i].dwz;
  372. }
  373. sWStationRecordData.time = DateTime.Now.ToString("MM/dd HH:mm");
  374. sWStationRecordData.stcd = GlobalData.swDatas[i].stcd;
  375. rescordSWStationData.Add(sWStationRecordData);
  376. }
  377. for (int i = 0; i < rescordSWStationData.Count; i++)
  378. {
  379. GameObject obj = Instantiate(thingPrefab);
  380. obj.GetComponent<RectTransform>().SetParent(thingParent);
  381. obj.transform.localScale = Vector3.one;
  382. obj.transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  383. string rescordSW_name = rescordSWStationData[i].name.ToString(); ;
  384. obj.transform.GetChild(1).GetComponent<Text>().text = rescordSW_name;
  385. obj.transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  386. obj.transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  387. string rescordSW_stcd = rescordSWStationData[i].stcd;
  388. obj.transform.GetComponent<Button>().onClick.AddListener(() =>
  389. {
  390. _waterTrendPanel.ShowTrend(rescordSW_stcd, rescordSW_name,0);
  391. });
  392. if (rescordSWStationData[i].dir == 0)
  393. {
  394. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  395. }
  396. else if (rescordSWStationData[i].dir == 1)
  397. {
  398. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  399. }
  400. else
  401. {
  402. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  403. }
  404. thing3s.Add(obj);
  405. }
  406. }
  407. else
  408. {
  409. for (int i = 0; i < GlobalData.swDatas.Count; i++)
  410. {
  411. rescordSWStationData[i].name = GlobalData.swDatas[i].stnm;
  412. // float lastValue = rescordSWStationData[i].value;
  413. float valueUpz = GlobalData.swDatas[i].upz == "-" ? float.MinValue : float.Parse(GlobalData.swDatas[i].upz);
  414. float valueDwz = GlobalData.swDatas[i].dwz == "-" ? float.MinValue : float.Parse(GlobalData.swDatas[i].dwz);
  415. if (valueUpz == float.MinValue && valueDwz == float.MinValue)
  416. {
  417. rescordSWStationData[i].value = "-";
  418. }
  419. else if (valueUpz == float.MinValue)
  420. {
  421. rescordSWStationData[i].value = GlobalData.swDatas[i].dwz;
  422. }
  423. else if (valueDwz == float.MinValue)
  424. {
  425. rescordSWStationData[i].value = GlobalData.swDatas[i].upz;
  426. }
  427. else
  428. {
  429. rescordSWStationData[i].value = (valueUpz > valueDwz) ? GlobalData.swDatas[i].upz : GlobalData.swDatas[i].dwz;
  430. }
  431. rescordSWStationData[i].time = DateTime.Now.ToString("MM/dd HH:mm");
  432. //if (rescordSWStationData[i].value > lastValue)
  433. //{
  434. // rescordSWStationData[i].dir = 1;
  435. //}
  436. //else if (rescordSWStationData[i].value > lastValue)
  437. //{
  438. // rescordSWStationData[i].dir = 0;
  439. //}
  440. //else
  441. //{
  442. // rescordSWStationData[i].dir = -1;
  443. //}
  444. }
  445. for (int i = 0; i < rescordSWStationData.Count; i++)
  446. {
  447. thing3s[i].transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  448. thing3s[i].transform.GetChild(1).GetComponent<Text>().text = rescordSWStationData[i].name.ToString();
  449. thing3s[i].transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  450. thing3s[i].transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  451. if (rescordSWStationData[i].dir == 0)
  452. {
  453. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  454. }
  455. else if (rescordSWStationData[i].dir == 1)
  456. {
  457. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  458. }
  459. else
  460. {
  461. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  462. }
  463. }
  464. }
  465. }
  466. async void InitRainInfo()
  467. {
  468. await new WaitUntil(() =>
  469. {
  470. return GlobalData.sWZDatas.Count > 0;
  471. });
  472. int swzCount = GlobalData.sWZDatas.Count;
  473. string maxName = "";
  474. float maxValue = -99f;
  475. int value010 = 0;
  476. int value1025 = 0;
  477. int value2550 = 0;
  478. int value50100 = 0;
  479. int value100200 = 0;
  480. int value200 = 0;
  481. for (int i = 0; i < swzCount; i++)
  482. {
  483. float value = GlobalData.sWZDatas[i].dropSum6;
  484. if (value > maxValue)
  485. {
  486. maxValue = value;
  487. maxName = GlobalData.sWZDatas[i].STNM;
  488. }
  489. if (value >= 0 && value < 10)
  490. {
  491. value010++;
  492. }
  493. else if (value >= 10 && value < 25)
  494. {
  495. value1025++;
  496. }
  497. else if (value >= 25 && value < 50)
  498. {
  499. value2550++;
  500. }
  501. else if (value >= 50 && value < 100)
  502. {
  503. value50100++;
  504. }
  505. else if (value >= 100 && value < 200)
  506. {
  507. value100200++;
  508. }
  509. else
  510. {
  511. value200++;
  512. }
  513. }
  514. rainText.text = $"数据时间:(过去24小时)\r\n蓄洪区共有{swzCount}个雨量站,其中几个雨量站监测有降雨最大降雨测站为{maxName}站点,降雨量{maxValue}mm.";
  515. rainTextNum[0].text = value010.ToString();
  516. rainTextNum[1].text = value1025.ToString();
  517. rainTextNum[2].text = value2550.ToString();
  518. rainTextNum[3].text = value50100.ToString();
  519. rainTextNum[4].text = value100200.ToString();
  520. rainTextNum[5].text = value200.ToString();
  521. }
  522. void InitLayerInfo()
  523. {
  524. //layerInfoBtns = layerInfo.GetComponentsInChildren<Button>();
  525. for (int i = 0; i < layerInfoBtns.Length; i++)
  526. {
  527. int temp = i;
  528. layerInfoBtns[i].onClick.AddListener(() =>
  529. {
  530. RunTimeLayerClick(temp);
  531. });
  532. }
  533. layerButton.onClick.AddListener(() =>
  534. {
  535. layerInfo.gameObject.SetActive(true);
  536. });
  537. layerInfoExitBtn.onClick.AddListener(() =>
  538. {
  539. layerInfo.gameObject.SetActive(false);
  540. });
  541. baseLayerInfoBtns[0].onClick.AddListener(() =>
  542. {
  543. bool active = baseLayerInfoBtns[0].GetComponent<CanvasGroup>().alpha > 0.5f;
  544. BaseLayer0BtnOnClick(!active);
  545. });
  546. baseLayerInfoBtns[0].GetComponent<CanvasGroup>().alpha = 0.5f;
  547. baseLayerInfoBtns[1].onClick.AddListener(() =>
  548. {
  549. bool active = baseLayerInfoBtns[1].GetComponent<CanvasGroup>().alpha > 0.5f;
  550. baseLayerInfoBtns[1].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
  551. bool newActive = !active;
  552. for (int i = 0; i < riverLayerObj.Length; i++)
  553. {
  554. riverLayerObj[i].gameObject.SetActive(newActive);
  555. riverLayerInfo[i].gameObject.SetActive(newActive);
  556. }
  557. });
  558. baseLayerInfoBtns[1].GetComponent<CanvasGroup>().alpha = 0.5f;
  559. baseLayerInfoBtns[2].onClick.AddListener(() =>
  560. {
  561. bool active = baseLayerInfoBtns[2].GetComponent<CanvasGroup>().alpha > 0.5f;
  562. BaseLayer2BtnOnClick(!active);
  563. });
  564. baseLayerInfoBtns[2].GetComponent<CanvasGroup>().alpha = 0.5f;
  565. for (int i = 0; i < regionObjParent2.transform.childCount; i++)
  566. {
  567. region2LayerObj.Add(regionObjParent2.transform.GetChild(i).gameObject);
  568. }
  569. baseLayerInfoBtns[3].onClick.AddListener(() =>
  570. {
  571. bool active = baseLayerInfoBtns[3].GetComponent<CanvasGroup>().alpha > 0.5f;
  572. BaseLayer3BtnOnClick(!active);
  573. });
  574. baseLayerInfoBtns[3].GetComponent<CanvasGroup>().alpha = 0.5f;
  575. baseLayerInfoBtns[4].onClick.AddListener(() =>
  576. {
  577. bool active = baseLayerInfoBtns[4].GetComponent<CanvasGroup>().alpha > 0.5f;
  578. BaseLayer4BtnOnClick(!active);
  579. });
  580. baseLayerInfoBtns[4].GetComponent<CanvasGroup>().alpha = 0.5f;
  581. }
  582. void BaseLayer0BtnOnClick(bool newActive)
  583. {
  584. baseLayerInfoBtns[0].GetComponent<CanvasGroup>().alpha = newActive ? 1f : 0.5f;
  585. if (newActive)
  586. {
  587. //BaseLayer2BtnOnClick(false);
  588. //BaseLayer3BtnOnClick(false);
  589. }
  590. for (int i = 0; i < regionLayerObj.Length; i++)
  591. {
  592. regionLayerObj[i].gameObject.SetActive(newActive);
  593. }
  594. }
  595. void BaseLayer2BtnOnClick(bool newActive)
  596. {
  597. if (newActive)
  598. {
  599. //BaseLayer0BtnOnClick(false);
  600. //BaseLayer3BtnOnClick(false);
  601. }
  602. baseLayerInfoBtns[2].GetComponent<CanvasGroup>().alpha = newActive ? 1f : 0.5f;
  603. for (int i = 0; i < lakeLayerObj.Length; i++)
  604. {
  605. lakeLayerObj[i].gameObject.SetActive(newActive);
  606. lakeLayerInfo[i].gameObject.SetActive(newActive);
  607. }
  608. }
  609. void BaseLayer3BtnOnClick(bool newActive)
  610. {
  611. if (newActive)
  612. {
  613. //BaseLayer0BtnOnClick(false);
  614. //BaseLayer2BtnOnClick(false);
  615. }
  616. baseLayerInfoBtns[3].GetComponent<CanvasGroup>().alpha = newActive ? 1f : 0.5f;
  617. for (int i = 0; i < region2LayerObj.Count; i++)
  618. {
  619. region2LayerObj[i].gameObject.SetActive(newActive);
  620. }
  621. }
  622. void BaseLayer4BtnOnClick(bool newActive)
  623. {
  624. if (newActive)
  625. {
  626. }
  627. baseLayerInfoBtns[4].GetComponent<CanvasGroup>().alpha = newActive ? 1f : 0.5f;
  628. for (int i = 0; i < aqqLayerObj.Length; i++)
  629. {
  630. aqqLayerObj[i].gameObject.SetActive(newActive);
  631. }
  632. }
  633. void RunTimeLayerClick(int temp)
  634. {
  635. bool active = layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha > 0.5f;
  636. layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
  637. bool newActive = !active;
  638. ChangeRuntimeLayer(temp, newActive);
  639. }
  640. void LeftBtnClick(int index, bool record = true)
  641. {
  642. if (record)
  643. currentActiveLeft = index;
  644. for (int i = 0; i < leftButtons.Length; i++)
  645. {
  646. leftButtons[i].GetComponent<Image>().sprite = sprites[1];
  647. }
  648. leftButtons[index].GetComponent<Image>().sprite = sprites[0];
  649. for (int i = 0; i < leftContent.childCount; i++)
  650. {
  651. leftContent.transform.GetChild(i).gameObject.SetActive(false);
  652. }
  653. leftContent.transform.GetChild(index).gameObject.SetActive(true);
  654. if (index == 1)
  655. {
  656. InitSWHeightInfo();
  657. }
  658. }
  659. void InitLayerBtns()
  660. {
  661. layerBtns = new List<LayerBtn>();
  662. for (int i = 0; i < layerDatas.Length; i++)
  663. {
  664. LayerBtn layerBtn = Instantiate(layerBtnPrefab);
  665. layerBtn.SetUseful(false);
  666. int index = i;
  667. int num = 0;
  668. if (i == 0)
  669. {
  670. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  671. for (int j = 0; j < tempDatas.Count; j++)
  672. {
  673. if (tempDatas[j].special == "1")
  674. {
  675. int tempJ = j;
  676. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  677. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  678. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  679. secLayerBtn.btn.onClick.AddListener(() =>
  680. {
  681. CameraManager.SwitchCamera(0);
  682. viewMode = ViewMode.normal;
  683. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  684. yZT.gameObject.SetActive(true);
  685. ChangeRightContent(tempJ);
  686. pointParent.gameObject.SetActive(false);
  687. clearBtn.gameObject.SetActive(false);
  688. middleContent.gameObject.SetActive(false);
  689. rightContent.gameObject.SetActive(false);
  690. LeftBtnClick(1, false);
  691. });
  692. num++;
  693. }
  694. }
  695. layerBtn.secContent.gameObject.SetActive(true);
  696. }
  697. else
  698. {
  699. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  700. for (int j = 0; j < tempDatas.Count; j++)
  701. {
  702. if ((int)tempDatas[j].type == layerDatas[i].layerID)
  703. {
  704. int tempJ = j;
  705. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  706. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  707. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  708. secLayerBtn.btn.onClick.AddListener(() =>
  709. {
  710. CameraManager.SwitchCamera(0);
  711. viewMode = ViewMode.normal;
  712. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
  713. yZT.gameObject.SetActive(true);
  714. ChangeRightContent(tempJ);
  715. pointParent.gameObject.SetActive(false);
  716. clearBtn.gameObject.SetActive(false);
  717. middleContent.gameObject.SetActive(false);
  718. rightContent.gameObject.SetActive(false);
  719. LeftBtnClick(1, false);
  720. });
  721. num++;
  722. }
  723. }
  724. }
  725. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  726. {
  727. for (int j = 0; j < layerBtns.Count; j++)
  728. {
  729. layerBtns[j].SetUseful(false);
  730. layerBtns[j].secContent.gameObject.SetActive(false);
  731. }
  732. layerBtns[index].SetUseful(true);
  733. layerBtns[index].secContent.gameObject.SetActive(true);
  734. //ChangeRuntimeLayer(index);
  735. });
  736. layerBtn.SetLayerBtnData(layerSprite[layerDatas[i].layerID], layerDatas[i].layerName, num.ToString());
  737. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  738. layerBtn.transform.localScale = Vector3.one;
  739. layerBtns.Add(layerBtn);
  740. }
  741. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  742. layerBtns[0].SetUseful(true);
  743. }
  744. void ChangeRightContent(int index)
  745. {
  746. int newIndex = index;
  747. if (newIndex > 120)
  748. {
  749. newIndex = newIndex - 58;
  750. }
  751. for (int i = 0; i < infoRight.childCount; i++)
  752. {
  753. infoRight.GetChild(i).gameObject.SetActive(false);
  754. }
  755. infoRight.GetChild(newIndex).gameObject.SetActive(true);
  756. GameObject title;
  757. GameObject text1;
  758. if (infoRight.GetChild(newIndex).GetComponentInChildren<ScrollRect>() != null)
  759. {
  760. title = infoRight.GetChild(newIndex).GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(1).gameObject;
  761. text1 = infoRight.GetChild(newIndex).GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(2).gameObject;
  762. }
  763. else {
  764. title = infoRight.GetChild(newIndex).GetChild(0).GetChild(1).gameObject;
  765. text1 = infoRight.GetChild(newIndex).GetChild(0).GetChild(2).gameObject;
  766. }
  767. if (title != null)
  768. {
  769. title.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].name;
  770. }
  771. if (text1 != null)
  772. {
  773. text1.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text1;
  774. }
  775. if (infoRight.GetChild(newIndex).GetChild(0).childCount > 3)
  776. {
  777. GameObject text2 = infoRight.GetChild(newIndex).GetChild(0).GetChild(3).gameObject;
  778. if (text2 != null)
  779. {
  780. text2.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text2;
  781. }
  782. }
  783. }
  784. void InitPoint()
  785. {
  786. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  787. List<Item0> item0s = new List<Item0>();
  788. for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
  789. {
  790. //if()
  791. HotPointData temp = GlobalData.hotPointDatas[i];
  792. Vector3 tempLocalPosition = CoordinateConverter.GeoToUGUISmall(temp.longitude, temp.latitude);
  793. RuntimePoint newPoint = Instantiate(pointPrefab, Vector3.zero, Quaternion.identity);
  794. int tempI = i;
  795. newPoint.GetComponent<RectTransform>().SetParent(pointParent);
  796. newPoint.InitPoint(hotPointSprite[(int)(temp.type)], temp.namePri, temp.name, temp.longitude, temp.latitude);
  797. newPoint.layerIDs.Add((int)(temp.type));
  798. newPoint.bingObj = Instantiate(runtimePointObj).gameObject;
  799. newPoint.bingObj.transform.SetParent(shaPan.transform.GetChild(8));
  800. newPoint.bingObj.transform.localEulerAngles = Vector3.zero;
  801. newPoint.bingObj.transform.localScale = Vector3.one;
  802. newPoint.bingObj.transform.localPosition = tempLocalPosition;
  803. newPoint.bingObj.name = temp.name;
  804. if ((int)temp.type == 6 || (int)temp.type == 7 || (int)temp.type == 9)
  805. {
  806. int index = FindIndexByLayerUnitName(temp.name);
  807. Item0 item0 = Instantiate(item0Prefab, Vector3.zero, Quaternion.identity);
  808. item0.InitPoint(hotPointSprite[(int)(temp.type)], temp.namePri, temp.name, GlobalData.layerUnitDatas[index].special);
  809. item0s.Add(item0);
  810. item0.onPointClick = () =>
  811. {
  812. OnNewPointClick(temp, item0);
  813. };
  814. }
  815. newPoint.onPointClick = () =>
  816. {
  817. OnNewPointClick(temp, newPoint);
  818. };
  819. runtimePointLib.Add(newPoint);
  820. }
  821. for (int i = 0; i < item0s.Count; i++)
  822. {
  823. if (item0s[i].mSpecial != "1")
  824. item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
  825. }
  826. for (int i = 0; i < item0s.Count; i++)
  827. {
  828. if (item0s[i].mSpecial == "1")
  829. item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
  830. }
  831. //Item0 item1 = Instantiate(item0Prefab, Vector3.zero, Quaternion.identity);
  832. //item1.GetComponent<RectTransform>().SetParent(item0Parent.transform);
  833. //item1.InitPoint(hotPointSprite[7], "GeTi", "隔堤", "1");
  834. RunTimeLayerClick(0);
  835. RunTimeLayerClick(1);
  836. RunTimeLayerClick(2);
  837. RunTimeLayerClick(3);
  838. RunTimeLayerClick(4);
  839. RunTimeLayerClick(5);
  840. RunTimeLayerClick(6);
  841. RunTimeLayerClick(8);
  842. RunTimeLayerClick(9);
  843. BaseLayer0BtnOnClick(true);
  844. }
  845. int FindIndexByLayerUnitName(string name)
  846. {
  847. for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
  848. {
  849. if (GlobalData.layerUnitDatas[i].name == name.Trim())
  850. {
  851. return i;
  852. }
  853. }
  854. return -1;
  855. }
  856. public static int FindIndexByHotPointName(string name)
  857. {
  858. string newName = name.Replace("(闸下)", "(闸下)").Replace("(闸上)", "(闸上)");
  859. newName = newName.TrimEnd();
  860. if (newName.Contains("补元"))
  861. {
  862. newName = "补元(闸上)";
  863. }
  864. else if (newName.Contains("套口"))
  865. {
  866. newName = "套口(闸上)";
  867. }
  868. Debug.Log(newName);
  869. for (int i = 0; i < GlobalData.swDatas.Count; i++)
  870. {
  871. Debug.Log(GlobalData.swDatas[i].stnm);
  872. if (GlobalData.swDatas[i].stnm.Trim() == newName.Trim())
  873. {
  874. return i;
  875. }
  876. }
  877. return -1;
  878. }
  879. public static int FindIndexBySWName(string name)
  880. {
  881. //string newName = name.Replace("(闸下)", "(下)").Replace("(闸上)", "(上)").Replace("(闸上)", "上").Replace("(闸下)", "下");
  882. //newName = newName.TrimEnd();
  883. //if (newName.Contains("补元"))
  884. //{
  885. // newName = "补元(上)";
  886. //}
  887. //else if (newName.Contains("套口"))
  888. //{
  889. // newName = "套口(上)";
  890. //}
  891. //Debug.Log(newName);
  892. for (int i = 0; i < GlobalData.sWZDatas.Count; i++)
  893. {
  894. //Debug.Log(GlobalData.swDatas[i].stnm);
  895. if (GlobalData.sWZDatas[i].STNM.Trim() == name.Trim())
  896. {
  897. return i;
  898. }
  899. }
  900. return -1;
  901. }
  902. void OnNewPointClick(HotPointData temp, RuntimePoint newPoint)
  903. {
  904. Debug.Log(temp.type);
  905. if ((int)temp.type == 4)
  906. {
  907. int index = FindIndexByHotPointName(temp.name);
  908. Debug.Log(GlobalData.swDatas[index].stcd);
  909. _waterTrendPanel.ShowTrend(GlobalData.swDatas[index].stcd, GlobalData.swDatas[index].stnm,0);
  910. }
  911. else if ((int)temp.type == 2) {
  912. int index = FindIndexBySWName(temp.name);
  913. Debug.Log(index);
  914. _waterTrendPanel.ShowTrend(GlobalData.sWZDatas[index].STCD, GlobalData.sWZDatas[index].STNM,1);
  915. }
  916. else if ((int)temp.type >= 6 || newPoint.layerIDs.Count > 4)
  917. {
  918. CameraManager.SwitchCamera(0);
  919. viewMode = ViewMode.normal;
  920. StaticLod.instance.OnFoucusStatic(newPoint.staticImp);
  921. yZT.gameObject.SetActive(true);
  922. int index = FindIndexByLayerUnitName(temp.name);
  923. ChangeRightContent(index);
  924. pointParent.gameObject.SetActive(false);
  925. clearBtn.gameObject.SetActive(false);
  926. middleContent.gameObject.SetActive(false);
  927. rightContent.gameObject.SetActive(false);
  928. LeftBtnClick(1, false);
  929. }
  930. }
  931. void OnNewPointClick(HotPointData temp, Item0 item0)
  932. {
  933. CameraManager.SwitchCamera(0);
  934. viewMode = ViewMode.normal;
  935. StaticLod.instance.OnFoucusStatic(item0.staticImp);
  936. yZT.gameObject.SetActive(true);
  937. int index = FindIndexByLayerUnitName(temp.name);
  938. ChangeRightContent(index);
  939. pointParent.gameObject.SetActive(false);
  940. clearBtn.gameObject.SetActive(false);
  941. middleContent.gameObject.SetActive(false);
  942. rightContent.gameObject.SetActive(false);
  943. LeftBtnClick(1, false);
  944. }
  945. async Task InitData()
  946. {
  947. await new WaitUntil(() =>
  948. {
  949. return GlobalData.layerUnitDatas.Count > 0;
  950. });
  951. }
  952. async Task InitPointData()
  953. {
  954. await new WaitUntil(() =>
  955. {
  956. return GlobalData.hotPointDatas.Count > 0;
  957. });
  958. }
  959. void Init()
  960. {
  961. yZT.gameObject.SetActive(false);
  962. clearBtn.gameObject.SetActive(true);
  963. pointParent.gameObject.SetActive(true);
  964. middleContent.gameObject.SetActive(true);
  965. rightContent.gameObject.SetActive(true);
  966. LeftBtnClick(currentActiveLeft);
  967. }
  968. void InitReturnBtn()
  969. {
  970. returnBtn.onClick.AddListener(() =>
  971. {
  972. CameraManager.SwitchCamera(1);
  973. viewMode = ViewMode.miniMap;
  974. Init();
  975. });
  976. }
  977. void ChangeRuntimeLayer(int layer, bool show)
  978. {
  979. if (show)
  980. {
  981. if (cancelLayer.Contains(layer))
  982. {
  983. cancelLayer.Remove(layer);
  984. }
  985. }
  986. else
  987. {
  988. if (!cancelLayer.Contains(layer))
  989. {
  990. cancelLayer.Add(layer);
  991. }
  992. }
  993. for (int i = 0; i < runtimePointLib.Count; i++)
  994. {
  995. if (runtimePointLib[i].layerIDs.Contains(layer))
  996. {
  997. if (runtimePointLib[i].layerIDs.Count < 2)
  998. {
  999. runtimePointLib[i].gameObject.SetActive(show);
  1000. }
  1001. else
  1002. {
  1003. List<int> tempLayers = new List<int>(runtimePointLib[i].layerIDs);
  1004. for (int j = 0; j < cancelLayer.Count; j++)
  1005. {
  1006. if (tempLayers.Contains(cancelLayer[j]))
  1007. {
  1008. tempLayers.Remove(cancelLayer[j]);
  1009. }
  1010. }
  1011. if (tempLayers.Count < 1)
  1012. {
  1013. runtimePointLib[i].gameObject.SetActive(false);
  1014. }
  1015. else
  1016. {
  1017. runtimePointLib[i].gameObject.SetActive(true);
  1018. }
  1019. }
  1020. }
  1021. }
  1022. }
  1023. void ShootRay()
  1024. {
  1025. Ray ray = CameraManager.instance.mainCamera.ScreenPointToRay(Input.mousePosition);
  1026. RaycastHit hit;
  1027. if (Physics.Raycast(ray, out hit, 20000, 1 << 8 | 1 << 9))
  1028. {
  1029. CameraBird bird = CameraManager.instance.mainCamera.GetComponent<CameraBird>();
  1030. if (hit.collider.gameObject.layer == LayerMask.NameToLayer("EarthTile"))
  1031. {
  1032. if (bird.transform.position.y > 1000)
  1033. {
  1034. bird.SetCameraToCenterFade(hit.point, 1100);
  1035. }
  1036. }
  1037. else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("StaticImportant"))
  1038. {
  1039. StaticImportant si = hit.collider.gameObject.GetComponent<StaticImportant>();
  1040. int index = StaticLod.instance.OnFoucusStatic(si);
  1041. yZT.gameObject.SetActive(true);
  1042. ChangeRightContent(index);
  1043. pointParent.gameObject.SetActive(false);
  1044. clearBtn.gameObject.SetActive(false);
  1045. middleContent.gameObject.SetActive(false);
  1046. rightContent.gameObject.SetActive(false);
  1047. LeftBtnClick(1, false);
  1048. }
  1049. }
  1050. else
  1051. {
  1052. Debug.Log("No hit");
  1053. }
  1054. }
  1055. private void OnEnable()
  1056. {
  1057. if (regionObjParent != null)
  1058. regionObjParent.transform.gameObject.SetActive(true);
  1059. if (regionObjParent2 != null)
  1060. regionObjParent2.transform.gameObject.SetActive(true);
  1061. }
  1062. private void OnDisable()
  1063. {
  1064. if (regionObjParent != null)
  1065. regionParent.transform.gameObject.SetActive(false);
  1066. if (regionObjParent2 != null)
  1067. regionObjParent2.transform.gameObject.SetActive(false);
  1068. }
  1069. private void Update()
  1070. {
  1071. if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击
  1072. {
  1073. clickInterval = 0.0f;
  1074. startClickPosition = Input.mousePosition;
  1075. }
  1076. clickInterval += Time.deltaTime;
  1077. if (Input.GetMouseButtonUp(0))
  1078. {
  1079. if (clickInterval < 0.2f && Vector3.Distance(startClickPosition, Input.mousePosition) < 10f)
  1080. {
  1081. if (!CameraManager.instance.secondCamera.enabled)
  1082. {
  1083. ShootRay();
  1084. }
  1085. }
  1086. }
  1087. }
  1088. private void LateUpdate()
  1089. {
  1090. if (CameraManager.instance.secondCamera.enabled)
  1091. {
  1092. regionParent.transform.gameObject.SetActive(true);
  1093. for (int i = 0; i < riverLayerInfo.Length; i++)
  1094. {
  1095. if (riverLayerInfo[i].gameObject.activeSelf)
  1096. {
  1097. riverLayerInfo[i].anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(riverLayerObj[i].transform.position) / Screen.width * 1920.0f;
  1098. }
  1099. }
  1100. for (int i = 0; i < lakeLayerInfo.Length; i++)
  1101. {
  1102. if (lakeLayerInfo[i].gameObject.activeSelf)
  1103. {
  1104. lakeLayerInfo[i].anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(lakeLayerObj[i].transform.position) / Screen.width * 1920.0f;
  1105. }
  1106. }
  1107. }
  1108. else
  1109. {
  1110. regionParent.transform.gameObject.SetActive(false);
  1111. }
  1112. }
  1113. }