YZTLayer.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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 Best.HTTP.Caching;
  13. [System.Serializable]
  14. public class YZTLayerData
  15. {
  16. public string layerName;
  17. public int layerID;
  18. }
  19. public enum LayerUnitType
  20. {
  21. ZZ = 1,
  22. BZ,
  23. NC,
  24. QXZ,
  25. JK,
  26. QT
  27. }
  28. [System.Serializable]
  29. public class LayerUnitData
  30. {
  31. public bool special;
  32. public LayerUnitType type;
  33. public float longitude;
  34. public float latitude;
  35. public string name;
  36. public string name_pri;
  37. public string text1;
  38. public string text2;
  39. public string GetTypeName()
  40. {
  41. string result = "";
  42. switch (type)
  43. {
  44. case LayerUnitType.ZZ:
  45. result = "闸站";
  46. break;
  47. case LayerUnitType.BZ:
  48. result = "泵站";
  49. break;
  50. case LayerUnitType.NC:
  51. result = "农场";
  52. break;
  53. case LayerUnitType.QXZ:
  54. result = "气象站";
  55. break;
  56. case LayerUnitType.JK:
  57. result = "监控";
  58. break;
  59. case LayerUnitType.QT:
  60. result = "其他";
  61. break;
  62. }
  63. return result;
  64. }
  65. }
  66. [System.Serializable]
  67. public class HotPointData
  68. {
  69. public LayerUnitType type;
  70. public float longitude;
  71. public float latitude;
  72. public string name;
  73. public string name_pri;
  74. }
  75. [System.Serializable]
  76. public class SWStationRecordData
  77. {
  78. public string name;
  79. public string time;
  80. public float value;
  81. public int dir;
  82. }
  83. public class YZTLayer : YZTRootLayer
  84. {
  85. public VerticalLayoutGroup content;
  86. public Sprite[] layerSprite;
  87. public Sprite[] hotPointSprite;
  88. public LayerBtn layerBtnPrefab;
  89. public SecLayerBtn secLayerBtnPrefab;
  90. public YZTLayerData[] layerDatas;
  91. public RectTransform leftContent;
  92. public RectTransform middleContent;
  93. public RectTransform rightContent;
  94. List<LayerBtn> layerBtns = new List<LayerBtn>();
  95. public RuntimePoint pointPrefab;
  96. public GameObject runtimePointObj;
  97. public RectTransform pointParent;
  98. List<RuntimePoint> runtimePointLib = new List<RuntimePoint>();
  99. public GameObject yZTMini;
  100. public GameObject yZT;
  101. public RectTransform infoRight;
  102. public Button returnBtn;
  103. private float clickInterval;
  104. private Vector3 startClickPosition;
  105. public Button[] leftButtons;
  106. public Button layerButton;
  107. public int currentActiveLeft = 0;
  108. public RectTransform layerInfo;
  109. public Button layerInfoExitBtn;
  110. public Button[] layerInfoBtns;
  111. public List<int> cancelLayer = new List<int>();
  112. public Sprite[] sprites;
  113. public Text rainText;
  114. public Text[] rainTextNum;
  115. public GameObject thingPrefab;
  116. public RectTransform thingParent;
  117. public List<SWStationRecordData> rescordSWStationData = new List<SWStationRecordData>();
  118. public List<GameObject> thing3s = new List<GameObject>();
  119. public Button clearBtn;
  120. // Start is called before the first frame update
  121. async void Awake()
  122. {
  123. viewMode = ViewMode.miniMap;
  124. await InitData();
  125. Init();
  126. InitLeftBtn();
  127. InitLayerInfo();
  128. InitLayerBtns();
  129. InitReturnBtn();
  130. InitRainInfo();
  131. InitSWHeightInfo();
  132. await InitPointData();
  133. InitPoint();
  134. }
  135. void InitLeftBtn() {
  136. for (int i = 0; i < leftButtons.Length; i++) {
  137. int temp = i;
  138. leftButtons[i].onClick.AddListener(() =>
  139. {
  140. LeftBtnClick(temp);
  141. });
  142. }
  143. LeftBtnClick(0);
  144. clearBtn.onClick.AddListener(() => {
  145. if (clearBtn.GetComponent<Image>().sprite == sprites[0])
  146. {
  147. clearBtn.GetComponent<Image>().sprite = sprites[1];
  148. leftContent.gameObject.SetActive(false);
  149. pointParent.gameObject.SetActive(true);
  150. middleContent.gameObject.SetActive(false);
  151. rightContent.gameObject.SetActive(false);
  152. clearBtn.GetComponent<RectTransform>().anchoredPosition = new Vector2(-827, clearBtn.GetComponent<RectTransform>().anchoredPosition.y);
  153. }
  154. else {
  155. clearBtn.GetComponent<Image>().sprite = sprites[0];
  156. leftContent.gameObject.SetActive(true);
  157. pointParent.gameObject.SetActive(true);
  158. middleContent.gameObject.SetActive(true);
  159. rightContent.gameObject.SetActive(true);
  160. clearBtn.GetComponent<RectTransform>().anchoredPosition = new Vector2(-457, clearBtn.GetComponent<RectTransform>().anchoredPosition.y);
  161. }
  162. });
  163. }
  164. async void InitSWHeightInfo() {
  165. await new WaitUntil(() => {
  166. return GlobalData.swDatas.Count > 0;
  167. });
  168. if (rescordSWStationData.Count < 1)
  169. {
  170. for (int i = 0; i < GlobalData.swDatas.Count; i++) {
  171. SWStationRecordData sWStationRecordData = new SWStationRecordData();
  172. sWStationRecordData.dir = 0;
  173. sWStationRecordData.name = GlobalData.swDatas[i].STNM;
  174. sWStationRecordData.value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz)?GlobalData.swDatas[i].upz:GlobalData.swDatas[i].dwz;
  175. sWStationRecordData.time = DateTime.Now.ToString("MM/dd HH:mm");
  176. rescordSWStationData.Add(sWStationRecordData);
  177. }
  178. for (int i = 0; i < rescordSWStationData.Count; i++)
  179. {
  180. GameObject obj = Instantiate(thingPrefab);
  181. obj.GetComponent<RectTransform>().SetParent(thingParent);
  182. obj.transform.localScale = Vector3.one;
  183. obj.transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  184. obj.transform.GetChild(1).GetComponent<Text>().text = rescordSWStationData[i].name.ToString();
  185. obj.transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  186. obj.transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  187. if (rescordSWStationData[i].dir == 0)
  188. {
  189. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  190. }
  191. else if (rescordSWStationData[i].dir == 1)
  192. {
  193. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  194. }
  195. else {
  196. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  197. }
  198. thing3s.Add(obj);
  199. }
  200. }
  201. else {
  202. for (int i = 0; i < GlobalData.swDatas.Count; i++)
  203. {
  204. rescordSWStationData[i].name = GlobalData.swDatas[i].STNM;
  205. float lastValue = rescordSWStationData[i].value;
  206. rescordSWStationData[i].value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz) ? GlobalData.swDatas[i].upz : GlobalData.swDatas[i].dwz;
  207. rescordSWStationData[i].time = DateTime.Now.ToString("MM/dd HH:mm");
  208. if (rescordSWStationData[i].value > lastValue)
  209. {
  210. rescordSWStationData[i].dir = 1;
  211. }
  212. else if (rescordSWStationData[i].value > lastValue)
  213. {
  214. rescordSWStationData[i].dir = 0;
  215. }
  216. else {
  217. rescordSWStationData[i].dir = -1;
  218. }
  219. }
  220. for (int i = 0; i < rescordSWStationData.Count; i++)
  221. {
  222. thing3s[i].transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  223. thing3s[i].transform.GetChild(1).GetComponent<Text>().text = rescordSWStationData[i].name.ToString();
  224. thing3s[i].transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  225. thing3s[i].transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  226. if (rescordSWStationData[i].dir == 0)
  227. {
  228. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  229. }
  230. else if (rescordSWStationData[i].dir == 1)
  231. {
  232. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  233. }
  234. else
  235. {
  236. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  237. }
  238. }
  239. }
  240. }
  241. async void InitRainInfo() {
  242. await new WaitUntil(() => {
  243. return GlobalData.qXZDatas.Count > 0;
  244. });
  245. int qxzCount = GlobalData.qXZDatas.Count;
  246. string maxName = "";
  247. float maxValue = -99f;
  248. int value010 = 0;
  249. int value1025 = 0;
  250. int value2550 = 0;
  251. int value50100 = 0;
  252. int value100200 = 0;
  253. int value200 = 0;
  254. for (int i = 0; i < qxzCount; i++) {
  255. float value = GlobalData.qXZDatas[i].dropSum6;
  256. if (value > maxValue) {
  257. maxValue = value;
  258. maxName = GlobalData.qXZDatas[i].STNM;
  259. }
  260. if (value >= 0 && value < 10)
  261. {
  262. value010++;
  263. }
  264. else if (value >= 10 && value < 25)
  265. {
  266. value1025++;
  267. }
  268. else if (value >= 25 && value < 50)
  269. {
  270. value2550++;
  271. }
  272. else if (value >= 50 && value < 100)
  273. {
  274. value50100++;
  275. }
  276. else if (value >= 100 && value < 200)
  277. {
  278. value100200++;
  279. }
  280. else
  281. {
  282. value200++;
  283. }
  284. }
  285. rainText.text = $"数据时间:17日12时至18日12时(过去24小时)\r\n蓄洪区共有{qxzCount}个雨量站,其中几个雨量站监测有降雨最大降雨测站为{maxName}站点,降雨量{maxValue}mm.";
  286. rainTextNum[0].text = value010.ToString();
  287. rainTextNum[1].text = value1025.ToString();
  288. rainTextNum[2].text = value2550.ToString();
  289. rainTextNum[3].text = value50100.ToString();
  290. rainTextNum[4].text = value100200.ToString();
  291. rainTextNum[5].text = value200.ToString();
  292. }
  293. void InitLayerInfo() {
  294. //layerInfoBtns = layerInfo.GetComponentsInChildren<Button>();
  295. for (int i = 0; i < layerInfoBtns.Length; i++) {
  296. int temp = i;
  297. layerInfoBtns[i].onClick.AddListener(() =>
  298. {
  299. RunTimeLayerClick(temp);
  300. });
  301. }
  302. layerButton.onClick.AddListener(() => {
  303. layerInfo.gameObject.SetActive(true);
  304. });
  305. layerInfoExitBtn.onClick.AddListener(() =>
  306. {
  307. layerInfo.gameObject.SetActive(false);
  308. });
  309. }
  310. void RunTimeLayerClick(int temp) {
  311. bool active = layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha > 0.5f;
  312. layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
  313. bool newActive = !active;
  314. ChangeRuntimeLayer(temp, newActive);
  315. }
  316. void LeftBtnClick(int index,bool record = true) {
  317. if(record)
  318. currentActiveLeft = index;
  319. for (int i = 0; i < leftButtons.Length; i++)
  320. {
  321. leftButtons[i].GetComponent<Image>().sprite = sprites[1];
  322. }
  323. leftButtons[index].GetComponent<Image>().sprite = sprites[0];
  324. for (int i = 0; i < leftContent.childCount; i++) {
  325. leftContent.transform.GetChild(i).gameObject.SetActive(false);
  326. }
  327. leftContent.transform.GetChild(index).gameObject.SetActive(true);
  328. if (index == 1) {
  329. InitSWHeightInfo();
  330. }
  331. }
  332. void InitLayerBtns()
  333. {
  334. layerBtns = new List<LayerBtn>();
  335. for (int i = 0; i < layerDatas.Length; i++)
  336. {
  337. LayerBtn layerBtn = Instantiate(layerBtnPrefab);
  338. layerBtn.SetUseful(false);
  339. int index = i;
  340. int num = 0;
  341. if (i == 0)
  342. {
  343. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  344. for (int j = 0; j < tempDatas.Count; j++)
  345. {
  346. if (tempDatas[j].special)
  347. {
  348. int tempJ = j;
  349. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  350. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  351. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  352. secLayerBtn.btn.onClick.AddListener(() => {
  353. CameraManager.SwitchCamera(0);
  354. viewMode = ViewMode.normal;
  355. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
  356. yZT.gameObject.SetActive(true);
  357. ChangeRightContent(tempJ);
  358. pointParent.gameObject.SetActive(false);
  359. clearBtn.gameObject.SetActive(false);
  360. middleContent.gameObject.SetActive(false);
  361. rightContent.gameObject.SetActive(false);
  362. LeftBtnClick(1, false);
  363. });
  364. num++;
  365. }
  366. }
  367. layerBtn.secContent.gameObject.SetActive(true);
  368. }
  369. else {
  370. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  371. for (int j = 0; j < tempDatas.Count; j++)
  372. {
  373. if ((int)tempDatas[j].type == layerDatas[i].layerID)
  374. {
  375. int tempJ = j;
  376. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  377. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  378. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  379. secLayerBtn.btn.onClick.AddListener(() => {
  380. CameraManager.SwitchCamera(0);
  381. viewMode = ViewMode.normal;
  382. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
  383. yZT.gameObject.SetActive(true);
  384. ChangeRightContent(tempJ);
  385. pointParent.gameObject.SetActive(false);
  386. clearBtn.gameObject.SetActive(false);
  387. middleContent.gameObject.SetActive(false);
  388. rightContent.gameObject.SetActive(false);
  389. LeftBtnClick(1, false);
  390. });
  391. num++;
  392. }
  393. }
  394. }
  395. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  396. {
  397. for (int j = 0; j < layerBtns.Count; j++)
  398. {
  399. layerBtns[j].SetUseful(false);
  400. layerBtns[j].secContent.gameObject.SetActive(false);
  401. }
  402. layerBtns[index].SetUseful(true);
  403. layerBtns[index].secContent.gameObject.SetActive(true);
  404. //ChangeRuntimeLayer(index);
  405. });
  406. layerBtn.SetLayerBtnData(layerSprite[layerDatas[i].layerID], layerDatas[i].layerName, num.ToString());
  407. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  408. layerBtn.transform.localScale = Vector3.one;
  409. layerBtns.Add(layerBtn);
  410. }
  411. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  412. layerBtns[0].SetUseful(true);
  413. }
  414. void ChangeRightContent(int index) {
  415. for (int i = 0; i < infoRight.childCount; i++) {
  416. infoRight.GetChild(i).gameObject.SetActive(false);
  417. }
  418. infoRight.GetChild(index).gameObject.SetActive(true);
  419. GameObject title = infoRight.GetChild(index).GetChild(0).GetChild(1).gameObject;
  420. GameObject text1 = infoRight.GetChild(index).GetChild(0).GetChild(2).gameObject;
  421. if (title != null)
  422. {
  423. title.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].name;
  424. }
  425. if (text1 != null)
  426. {
  427. text1.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text1;
  428. }
  429. if (infoRight.GetChild(index).GetChild(0).childCount > 3)
  430. {
  431. GameObject text2 = infoRight.GetChild(index).GetChild(0).GetChild(3).gameObject;
  432. if (text2 != null)
  433. {
  434. text2.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text2;
  435. }
  436. }
  437. }
  438. void InitPoint()
  439. {
  440. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  441. for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
  442. {
  443. HotPointData temp = GlobalData.hotPointDatas[i];
  444. Vector3 tempLocalPosition = CoordinateConverter.GeoToUGUISmall(temp.longitude, temp.latitude);
  445. //bool have = false;
  446. //for (int j = 0; j < runtimePointLib.Count; j++)
  447. //{
  448. // if (Vector3.Distance(tempLocalPosition, runtimePointLib[j].bingObj.transform.localPosition) < 0.1)
  449. // {
  450. // if (runtimePointLib[j].layerIDs.Contains((int)temp.type))
  451. // {
  452. // have = true;
  453. // break;
  454. // }
  455. // else {
  456. // have = true;
  457. // runtimePointLib[j].Refresh(hotPointSprite[8]);
  458. // runtimePointLib[j].layerIDs.Add((int)temp.type);
  459. // break;
  460. // }
  461. // }
  462. //}
  463. //if (have) {
  464. // continue;
  465. //}
  466. RuntimePoint newPoint = Instantiate(pointPrefab, Vector3.zero, Quaternion.identity);
  467. int tempI = i;
  468. newPoint.GetComponent<RectTransform>().SetParent(pointParent);
  469. newPoint.InitPoint(hotPointSprite[(int)(temp.type)], temp.name_pri, temp.name);;
  470. newPoint.layerIDs.Add((int)(temp.type));
  471. newPoint.bingObj = Instantiate(runtimePointObj).gameObject;
  472. newPoint.bingObj.transform.SetParent(shaPan.transform.GetChild(6));
  473. newPoint.bingObj.transform.localEulerAngles = Vector3.zero;
  474. newPoint.bingObj.transform.localScale = Vector3.one;
  475. newPoint.bingObj.transform.localPosition = tempLocalPosition;
  476. newPoint.bingObj.name = temp.name;
  477. newPoint.onPointClick = () =>
  478. {
  479. OnNewPointClick(temp, newPoint);
  480. };
  481. runtimePointLib.Add(newPoint);
  482. }
  483. RunTimeLayerClick(0);
  484. RunTimeLayerClick(1);
  485. RunTimeLayerClick(2);
  486. RunTimeLayerClick(3);
  487. RunTimeLayerClick(4);
  488. RunTimeLayerClick(5);
  489. }
  490. int FindIndexByLayerUnitName(string name) {
  491. for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++) {
  492. if (GlobalData.layerUnitDatas[i].name == name.Trim()) {
  493. return i;
  494. }
  495. }
  496. return -1;
  497. }
  498. void OnNewPointClick(HotPointData temp, RuntimePoint newPoint)
  499. {
  500. if ((int)temp.type == 4)
  501. {
  502. OnePicNav.instance.SwitchToGlobalWaterHeight();
  503. }
  504. else if ((int)temp.type >= 6 || newPoint.layerIDs.Count > 4)
  505. {
  506. Debug.Log(1111111111111);
  507. CameraManager.SwitchCamera(0);
  508. viewMode = ViewMode.normal;
  509. StaticLod.instance.OnFoucusStatic(newPoint.staticImp);
  510. yZT.gameObject.SetActive(true);
  511. int index = FindIndexByLayerUnitName(temp.name);
  512. ChangeRightContent(index);
  513. pointParent.gameObject.SetActive(false);
  514. clearBtn.gameObject.SetActive(false);
  515. middleContent.gameObject.SetActive(false);
  516. rightContent.gameObject.SetActive(false);
  517. LeftBtnClick(1, false);
  518. }
  519. }
  520. async Task InitData() {
  521. await new WaitUntil(() => {
  522. return GlobalData.layerUnitDatas.Count > 0;
  523. });
  524. }
  525. async Task InitPointData()
  526. {
  527. await new WaitUntil(() =>
  528. {
  529. return GlobalData.hotPointDatas.Count > 0;
  530. });
  531. }
  532. void Init() {
  533. yZT.gameObject.SetActive(false);
  534. clearBtn.gameObject.SetActive(true);
  535. pointParent.gameObject.SetActive(true);
  536. middleContent.gameObject.SetActive(true);
  537. rightContent.gameObject.SetActive(true);
  538. LeftBtnClick(currentActiveLeft);
  539. }
  540. void InitReturnBtn() {
  541. returnBtn.onClick.AddListener(() =>
  542. {
  543. CameraManager.SwitchCamera(1);
  544. viewMode = ViewMode.miniMap;
  545. Init();
  546. });
  547. }
  548. void ChangeRuntimeLayer(int layer,bool show) {
  549. if (show)
  550. {
  551. if (cancelLayer.Contains(layer))
  552. {
  553. cancelLayer.Remove(layer);
  554. }
  555. }
  556. else {
  557. if (!cancelLayer.Contains(layer))
  558. {
  559. cancelLayer.Add(layer);
  560. }
  561. }
  562. for (int i = 0; i < runtimePointLib.Count; i++) {
  563. if (runtimePointLib[i].layerIDs.Contains(layer)) {
  564. if (runtimePointLib[i].layerIDs.Count < 2)
  565. {
  566. runtimePointLib[i].gameObject.SetActive(show);
  567. }
  568. else {
  569. List<int> tempLayers = new List<int>(runtimePointLib[i].layerIDs);
  570. for (int j = 0; j < cancelLayer.Count; j++) {
  571. if (tempLayers.Contains(cancelLayer[j])) {
  572. tempLayers.Remove(cancelLayer[j]);
  573. }
  574. }
  575. if (tempLayers.Count < 1)
  576. {
  577. runtimePointLib[i].gameObject.SetActive(false);
  578. }
  579. else {
  580. runtimePointLib[i].gameObject.SetActive(true);
  581. }
  582. }
  583. }
  584. }
  585. }
  586. void ShootRay()
  587. {
  588. Ray ray = CameraManager.instance.mainCamera.ScreenPointToRay(Input.mousePosition);
  589. RaycastHit hit;
  590. if (Physics.Raycast(ray, out hit,20000,1<<8|1<<9))
  591. {
  592. CameraBird bird = CameraManager.instance.mainCamera.GetComponent<CameraBird>();
  593. if (hit.collider.gameObject.layer == LayerMask.NameToLayer("EarthTile"))
  594. {
  595. if(bird.transform.position.y > 1000)
  596. {
  597. bird.SetCameraToCenterFade(hit.point, 1100);
  598. }
  599. }
  600. else if(hit.collider.gameObject.layer == LayerMask.NameToLayer("StaticImportant"))
  601. {
  602. StaticImportant si = hit.collider.gameObject.GetComponent<StaticImportant>();
  603. int index = StaticLod.instance.OnFoucusStatic(si);
  604. yZT.gameObject.SetActive(true);
  605. ChangeRightContent(index);
  606. pointParent.gameObject.SetActive(false);
  607. clearBtn.gameObject.SetActive(false);
  608. middleContent.gameObject.SetActive(false);
  609. rightContent.gameObject.SetActive(false);
  610. LeftBtnClick(1,false);
  611. }
  612. }
  613. else
  614. {
  615. Debug.Log("No hit");
  616. }
  617. }
  618. private void Update()
  619. {
  620. if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击
  621. {
  622. clickInterval = 0.0f;
  623. startClickPosition = Input.mousePosition;
  624. }
  625. clickInterval += Time.deltaTime;
  626. if (Input.GetMouseButtonUp(0)) {
  627. if (clickInterval < 0.2f && Vector3.Distance(startClickPosition,Input.mousePosition) < 10f) {
  628. if (!CameraManager.instance.secondCamera.enabled)
  629. {
  630. ShootRay();
  631. }
  632. }
  633. }
  634. }
  635. }