YZTLayer.cs 24 KB

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