YZTLayer.cs 44 KB

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