YZTLayer.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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 List<int> cancelLayer = new List<int>();
  111. public Sprite[] sprites;
  112. public Text rainText;
  113. public Text[] rainTextNum;
  114. public GameObject thingPrefab;
  115. public RectTransform thingParent;
  116. public List<SWStationRecordData> rescordSWStationData = new List<SWStationRecordData>();
  117. public List<GameObject> thing3s = new List<GameObject>();
  118. // Start is called before the first frame update
  119. async void Awake()
  120. {
  121. viewMode = ViewMode.miniMap;
  122. await InitData();
  123. Init();
  124. InitLeftBtn();
  125. InitLayerInfo();
  126. InitLayerBtns();
  127. InitReturnBtn();
  128. InitRainInfo();
  129. InitSWHeightInfo();
  130. await InitPointData();
  131. InitPoint();
  132. }
  133. void InitLeftBtn() {
  134. for (int i = 0; i < leftButtons.Length; i++) {
  135. int temp = i;
  136. leftButtons[i].onClick.AddListener(() =>
  137. {
  138. LeftBtnClick(temp);
  139. });
  140. }
  141. LeftBtnClick(0);
  142. }
  143. async void InitSWHeightInfo() {
  144. await new WaitUntil(() => {
  145. return GlobalData.swDatas.Count > 0;
  146. });
  147. if (rescordSWStationData.Count < 1)
  148. {
  149. for (int i = 0; i < GlobalData.swDatas.Count; i++) {
  150. SWStationRecordData sWStationRecordData = new SWStationRecordData();
  151. sWStationRecordData.dir = 0;
  152. sWStationRecordData.name = GlobalData.swDatas[i].STNM;
  153. sWStationRecordData.value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz)?GlobalData.swDatas[i].upz:GlobalData.swDatas[i].dwz;
  154. sWStationRecordData.time = DateTime.Now.ToString("MM/dd HH:mm");
  155. rescordSWStationData.Add(sWStationRecordData);
  156. }
  157. for (int i = 0; i < rescordSWStationData.Count; i++)
  158. {
  159. GameObject obj = Instantiate(thingPrefab);
  160. obj.GetComponent<RectTransform>().SetParent(thingParent);
  161. obj.transform.localScale = Vector3.one;
  162. obj.transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  163. obj.transform.GetChild(1).GetComponent<Text>().text = rescordSWStationData[i].name.ToString();
  164. obj.transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  165. obj.transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  166. if (rescordSWStationData[i].dir == 0)
  167. {
  168. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  169. }
  170. else if (rescordSWStationData[i].dir == 1)
  171. {
  172. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  173. }
  174. else {
  175. obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  176. }
  177. thing3s.Add(obj);
  178. }
  179. }
  180. else {
  181. for (int i = 0; i < GlobalData.swDatas.Count; i++)
  182. {
  183. rescordSWStationData[i].name = GlobalData.swDatas[i].STNM;
  184. float lastValue = rescordSWStationData[i].value;
  185. rescordSWStationData[i].value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz) ? GlobalData.swDatas[i].upz : GlobalData.swDatas[i].dwz;
  186. rescordSWStationData[i].time = DateTime.Now.ToString("MM/dd HH:mm");
  187. if (rescordSWStationData[i].value > lastValue)
  188. {
  189. rescordSWStationData[i].dir = 1;
  190. }
  191. else if (rescordSWStationData[i].value > lastValue)
  192. {
  193. rescordSWStationData[i].dir = 0;
  194. }
  195. else {
  196. rescordSWStationData[i].dir = -1;
  197. }
  198. }
  199. for (int i = 0; i < rescordSWStationData.Count; i++)
  200. {
  201. thing3s[i].transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
  202. thing3s[i].transform.GetChild(1).GetComponent<Text>().text = rescordSWStationData[i].name.ToString();
  203. thing3s[i].transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
  204. thing3s[i].transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
  205. if (rescordSWStationData[i].dir == 0)
  206. {
  207. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 0);
  208. }
  209. else if (rescordSWStationData[i].dir == 1)
  210. {
  211. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
  212. }
  213. else
  214. {
  215. thing3s[i].transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
  216. }
  217. }
  218. }
  219. }
  220. async void InitRainInfo() {
  221. await new WaitUntil(() => {
  222. return GlobalData.qXZDatas.Count > 0;
  223. });
  224. int qxzCount = GlobalData.qXZDatas.Count;
  225. string maxName = "";
  226. float maxValue = -99f;
  227. int value010 = 0;
  228. int value1025 = 0;
  229. int value2550 = 0;
  230. int value50100 = 0;
  231. int value100200 = 0;
  232. int value200 = 0;
  233. for (int i = 0; i < qxzCount; i++) {
  234. float value = GlobalData.qXZDatas[i].dropSum6;
  235. if (value > maxValue) {
  236. maxValue = value;
  237. maxName = GlobalData.qXZDatas[i].STNM;
  238. }
  239. if (value >= 0 && value < 10)
  240. {
  241. value010++;
  242. }
  243. else if (value >= 10 && value < 25)
  244. {
  245. value1025++;
  246. }
  247. else if (value >= 25 && value < 50)
  248. {
  249. value2550++;
  250. }
  251. else if (value >= 50 && value < 100)
  252. {
  253. value50100++;
  254. }
  255. else if (value >= 100 && value < 200)
  256. {
  257. value100200++;
  258. }
  259. else
  260. {
  261. value200++;
  262. }
  263. }
  264. rainText.text = $"数据时间:17日12时至18日12时(过去24小时)\r\n蓄洪区共有{qxzCount}个雨量站,其中几个雨量站监测有降雨最大降雨测站为{maxName}站点,降雨量{maxValue}mm.";
  265. rainTextNum[0].text = value010.ToString();
  266. rainTextNum[1].text = value1025.ToString();
  267. rainTextNum[2].text = value2550.ToString();
  268. rainTextNum[3].text = value50100.ToString();
  269. rainTextNum[4].text = value100200.ToString();
  270. rainTextNum[5].text = value200.ToString();
  271. }
  272. void InitLayerInfo() {
  273. Button[] btns = layerInfo.GetComponentsInChildren<Button>();
  274. for (int i = 0; i < btns.Length - 2; i++) {
  275. int temp = i;
  276. btns[i].onClick.AddListener(() =>
  277. {
  278. bool active = btns[temp].GetComponent<CanvasGroup>().alpha > 0.5f;
  279. btns[temp].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
  280. bool newActive = !active;
  281. ChangeRuntimeLayer(temp, newActive);
  282. });
  283. }
  284. layerButton.onClick.AddListener(() => {
  285. layerInfo.gameObject.SetActive(true);
  286. });
  287. layerInfoExitBtn.onClick.AddListener(() =>
  288. {
  289. layerInfo.gameObject.SetActive(false);
  290. });
  291. }
  292. void LeftBtnClick(int index,bool record = true) {
  293. if(record)
  294. currentActiveLeft = index;
  295. for (int i = 0; i < leftButtons.Length; i++)
  296. {
  297. leftButtons[i].GetComponent<Image>().sprite = sprites[1];
  298. }
  299. leftButtons[index].GetComponent<Image>().sprite = sprites[0];
  300. for (int i = 0; i < leftContent.childCount; i++) {
  301. leftContent.transform.GetChild(i).gameObject.SetActive(false);
  302. }
  303. leftContent.transform.GetChild(index).gameObject.SetActive(true);
  304. if (index == 1) {
  305. InitSWHeightInfo();
  306. }
  307. }
  308. void InitLayerBtns()
  309. {
  310. layerBtns = new List<LayerBtn>();
  311. for (int i = 0; i < layerDatas.Length; i++)
  312. {
  313. LayerBtn layerBtn = Instantiate(layerBtnPrefab);
  314. layerBtn.SetUseful(false);
  315. int index = i;
  316. int num = 0;
  317. if (i == 0)
  318. {
  319. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  320. for (int j = 0; j < tempDatas.Count; j++)
  321. {
  322. if (tempDatas[j].special)
  323. {
  324. int tempJ = j;
  325. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  326. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  327. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  328. secLayerBtn.btn.onClick.AddListener(() => {
  329. CameraManager.SwitchCamera(0);
  330. viewMode = ViewMode.normal;
  331. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
  332. yZT.gameObject.SetActive(true);
  333. ChangeRightContent(tempJ);
  334. middleContent.gameObject.SetActive(false);
  335. rightContent.gameObject.SetActive(false);
  336. LeftBtnClick(1, false);
  337. });
  338. num++;
  339. }
  340. }
  341. layerBtn.secContent.gameObject.SetActive(true);
  342. }
  343. else {
  344. List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
  345. for (int j = 0; j < tempDatas.Count; j++)
  346. {
  347. if ((int)tempDatas[j].type == layerDatas[i].layerID)
  348. {
  349. int tempJ = j;
  350. SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
  351. secLayerBtn.SetLayerBtnData(tempDatas[j].name);
  352. secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
  353. secLayerBtn.btn.onClick.AddListener(() => {
  354. CameraManager.SwitchCamera(0);
  355. viewMode = ViewMode.normal;
  356. StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
  357. yZT.gameObject.SetActive(true);
  358. ChangeRightContent(tempJ);
  359. middleContent.gameObject.SetActive(false);
  360. rightContent.gameObject.SetActive(false);
  361. LeftBtnClick(1, false);
  362. });
  363. num++;
  364. }
  365. }
  366. }
  367. layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
  368. {
  369. for (int j = 0; j < layerBtns.Count; j++)
  370. {
  371. layerBtns[j].SetUseful(false);
  372. layerBtns[j].secContent.gameObject.SetActive(false);
  373. }
  374. layerBtns[index].SetUseful(true);
  375. layerBtns[index].secContent.gameObject.SetActive(true);
  376. //ChangeRuntimeLayer(index);
  377. });
  378. layerBtn.SetLayerBtnData(layerSprite[layerDatas[i].layerID], layerDatas[i].layerName, num.ToString());
  379. layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
  380. layerBtn.transform.localScale = Vector3.one;
  381. layerBtns.Add(layerBtn);
  382. }
  383. content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  384. layerBtns[0].SetUseful(true);
  385. }
  386. void ChangeRightContent(int index) {
  387. for (int i = 0; i < infoRight.childCount; i++) {
  388. infoRight.GetChild(i).gameObject.SetActive(false);
  389. }
  390. infoRight.GetChild(index).gameObject.SetActive(true);
  391. GameObject title = infoRight.GetChild(index).GetChild(0).GetChild(1).gameObject;
  392. GameObject text1 = infoRight.GetChild(index).GetChild(0).GetChild(2).gameObject;
  393. if (title != null)
  394. {
  395. title.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].name;
  396. }
  397. if (text1 != null)
  398. {
  399. text1.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text1;
  400. }
  401. if (infoRight.GetChild(index).GetChild(0).childCount > 3)
  402. {
  403. GameObject text2 = infoRight.GetChild(index).GetChild(0).GetChild(3).gameObject;
  404. if (text2 != null)
  405. {
  406. text2.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].text2;
  407. }
  408. }
  409. }
  410. void InitPoint()
  411. {
  412. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  413. for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
  414. {
  415. HotPointData temp = GlobalData.hotPointDatas[i];
  416. Vector3 tempLocalPosition = CoordinateConverter.GeoToUGUISmall(temp.longitude, temp.latitude);
  417. bool have = false;
  418. for (int j = 0; j < runtimePointLib.Count; j++)
  419. {
  420. if (Vector3.Distance(tempLocalPosition, runtimePointLib[j].bingObj.transform.localPosition) < 0.1)
  421. {
  422. if (runtimePointLib[j].layerIDs.Contains((int)temp.type))
  423. {
  424. have = true;
  425. break;
  426. }
  427. else {
  428. have = true;
  429. runtimePointLib[j].Refresh(hotPointSprite[8]);
  430. runtimePointLib[j].layerIDs.Add((int)temp.type);
  431. break;
  432. }
  433. }
  434. }
  435. if (have) {
  436. continue;
  437. }
  438. RuntimePoint newPoint = Instantiate(pointPrefab, Vector3.zero, Quaternion.identity);
  439. int tempI = i;
  440. newPoint.GetComponent<RectTransform>().SetParent(pointParent);
  441. newPoint.InitPoint(hotPointSprite[(int)(temp.type)], temp.name_pri, temp.name);;
  442. newPoint.layerIDs.Add((int)(temp.type));
  443. newPoint.bingObj = Instantiate(runtimePointObj).gameObject;
  444. newPoint.bingObj.transform.SetParent(shaPan.transform.GetChild(6));
  445. newPoint.bingObj.transform.localEulerAngles = Vector3.zero;
  446. newPoint.bingObj.transform.localScale = Vector3.one;
  447. newPoint.bingObj.transform.localPosition = tempLocalPosition;
  448. newPoint.bingObj.name = temp.name;
  449. newPoint.onChildClick += OnChooseNewPointClick;
  450. newPoint.onPointClick = () =>
  451. {
  452. OnChooseNewPointClick(temp, newPoint);
  453. };
  454. runtimePointLib.Add(newPoint);
  455. }
  456. }
  457. void OnChooseNewPointClick(int selectIndex, RuntimePoint newPoint) {
  458. if (selectIndex == 0 || selectIndex == 3 || selectIndex == 5)
  459. {
  460. OnePicNav.instance.OnButtnClick(2);
  461. }
  462. else if (selectIndex == 1 || selectIndex == 2)
  463. {
  464. OnePicNav.instance.SwitchToGlobalWeather();
  465. }
  466. else if (selectIndex == 4)
  467. {
  468. OnePicNav.instance.SwitchToGlobalWaterHeight();
  469. }
  470. else if (selectIndex >= 6)
  471. {
  472. CameraManager.SwitchCamera(0);
  473. viewMode = ViewMode.normal;
  474. StaticLod.instance.OnFoucusStatic(newPoint.staticImp);
  475. yZT.gameObject.SetActive(true);
  476. int index = FindIndexByLayerUnitName(newPoint.bingObj.gameObject.name);
  477. ChangeRightContent(index);
  478. middleContent.gameObject.SetActive(false);
  479. rightContent.gameObject.SetActive(false);
  480. LeftBtnClick(1, false);
  481. }
  482. }
  483. int FindIndexByLayerUnitName(string name) {
  484. for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++) {
  485. if (GlobalData.layerUnitDatas[i].name == name.Trim()) {
  486. return i;
  487. }
  488. }
  489. return -1;
  490. }
  491. void OnChooseNewPointClick(HotPointData temp, RuntimePoint newPoint) {
  492. if (newPoint.layerIDs.Count < 2)
  493. {
  494. OnNewPointClick(temp, newPoint);
  495. }
  496. }
  497. void OnNewPointClick(HotPointData temp, RuntimePoint newPoint)
  498. {
  499. if ((int)temp.type == 0 || (int)temp.type == 3 || (int)temp.type == 5) {
  500. OnePicNav.instance.OnButtnClick(2);
  501. }
  502. else if ((int)temp.type == 1 || (int)temp.type == 2) {
  503. OnePicNav.instance.SwitchToGlobalWeather();
  504. }
  505. else if ((int)temp.type == 4)
  506. {
  507. OnePicNav.instance.SwitchToGlobalWaterHeight();
  508. }
  509. else if ((int)temp.type >= 6)
  510. {
  511. CameraManager.SwitchCamera(0);
  512. viewMode = ViewMode.normal;
  513. StaticLod.instance.OnFoucusStatic(newPoint.staticImp);
  514. yZT.gameObject.SetActive(true);
  515. int index = FindIndexByLayerUnitName(temp.name);
  516. ChangeRightContent(index);
  517. middleContent.gameObject.SetActive(false);
  518. rightContent.gameObject.SetActive(false);
  519. LeftBtnClick(1, false);
  520. }
  521. }
  522. async Task InitData() {
  523. await new WaitUntil(() => {
  524. return GlobalData.layerUnitDatas.Count > 0;
  525. });
  526. }
  527. async Task InitPointData()
  528. {
  529. await new WaitUntil(() =>
  530. {
  531. return GlobalData.hotPointDatas.Count > 0;
  532. });
  533. }
  534. void Init() {
  535. yZT.gameObject.SetActive(false);
  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. middleContent.gameObject.SetActive(false);
  607. rightContent.gameObject.SetActive(false);
  608. LeftBtnClick(1,false);
  609. }
  610. }
  611. else
  612. {
  613. Debug.Log("No hit");
  614. }
  615. }
  616. private void Update()
  617. {
  618. if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击
  619. {
  620. clickInterval = 0.0f;
  621. startClickPosition = Input.mousePosition;
  622. }
  623. clickInterval += Time.deltaTime;
  624. if (Input.GetMouseButtonUp(0)) {
  625. if (clickInterval < 0.2f && Vector3.Distance(startClickPosition,Input.mousePosition) < 10f) {
  626. if (!CameraManager.instance.secondCamera.enabled)
  627. {
  628. ShootRay();
  629. }
  630. }
  631. }
  632. }
  633. }