RKZYLayer.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. using Best.HTTP.Shared.Compression.Zlib;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9. using Unity.VisualScripting;
  10. using UnityAsync;
  11. using UnityEngine;
  12. using UnityEngine.Networking;
  13. using UnityEngine.UI;
  14. using WaitUntil = UnityAsync.WaitUntil;
  15. [System.Serializable]
  16. public class MovePlan
  17. {
  18. public string startPos;
  19. public string endPos;
  20. public int humanNum;
  21. public string time;
  22. }
  23. [System.Serializable]
  24. public class MoveAtten
  25. {
  26. public string title;
  27. public string pos;
  28. public string time;
  29. }
  30. [System.Serializable]
  31. public class MovePath
  32. {
  33. public MovePath(double l1, double l2)
  34. {
  35. longitude = l1;
  36. latitude = l2;
  37. }
  38. public double longitude;
  39. public double latitude;
  40. }
  41. [System.Serializable]
  42. public class ServerMovePlan {
  43. public bool isAfter;
  44. public bool isOut;
  45. public string desc;
  46. public string from;
  47. public float fromLong;
  48. public float fromLttd;
  49. public string to;
  50. public float toLong;
  51. public float toLttd;
  52. public int manNum;
  53. public int homeNum;
  54. public int completeNum;
  55. public string dateTime;
  56. public int villageCount;
  57. public int materialPrize;
  58. public List<MovePath> paths = new List<MovePath>();
  59. }
  60. [System.Serializable]
  61. public class ZYYAData
  62. {
  63. public int totalRoadCount;
  64. public float totalmanNum;
  65. public int totalVillageCount;
  66. public float totalMaterialPrize;
  67. }
  68. public class RKZYLayer : YZTRootLayer
  69. {
  70. public Text timeText;
  71. public LineInfo lineInfo;
  72. //public List<MovePlan> movePlans;
  73. public List<Thing1> movePlans;
  74. public List<MoveAtten> moveAttens;
  75. public static LineInfo lineInfoStatic;
  76. public Button beforeBtn;
  77. public Button afterBtn;
  78. public Button[] allInOut;
  79. public Transform beforeC;
  80. public Transform afterC;
  81. public List<LinePath> linePaths = new List<LinePath>();
  82. public Sprite[] sprites;
  83. public int inOutIndex;
  84. public int beforeAfterIndex;
  85. public RectTransform title1;
  86. public RectTransform plan1;
  87. public RectTransform movePlanBeforeContent;
  88. public RectTransform movePlanAfterContent;
  89. public RectTransform title2;
  90. public RectTransform plan2;
  91. public RectTransform attenContent;
  92. public Text[] zYGKText;
  93. public ZYYAData[] zYYADatas;
  94. public int zYYAIndex = 0;
  95. public Text[] zYYAText;
  96. public Material afterMat;
  97. public LinePathUnit linePathUnitPrefab;
  98. public LinePath linePathPrefab;
  99. public RectTransform startPos;
  100. public RectTransform endPos;
  101. public RectTransform pathSign;
  102. // Start is called before the first frame update
  103. async void Start()
  104. {
  105. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  106. beforeC.gameObject.SetActive(true);
  107. beforeC = shaPan.transform.GetChild(12);
  108. afterC = shaPan.transform.GetChild(13);
  109. lineInfoStatic = lineInfo;
  110. await InitMovePlan();
  111. //TODO 这一块的path应该从movePlan里面生成而不是默认
  112. InitAllPath();
  113. InitButton();
  114. InitAtten();
  115. await InitBaseData();
  116. }
  117. public override void OnUILeave()
  118. {
  119. base.OnUILeave();
  120. beforeC.gameObject.SetActive(false);
  121. afterC.gameObject.SetActive(false);
  122. }
  123. private void OnEnable()
  124. {
  125. CameraManager.SwitchCamera(1);
  126. }
  127. void InitAtten() {
  128. RectTransform title = Instantiate(title2);
  129. title.SetParent(attenContent);
  130. title.localScale = Vector3.one;
  131. for (int i = 0; i < moveAttens.Count; i++)
  132. {
  133. RectTransform plan = Instantiate(plan2);
  134. plan.SetParent(attenContent);
  135. plan.localScale = Vector3.one;
  136. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  137. plan.GetChild(1).GetComponent<Text>().text = moveAttens[i].title;
  138. plan.GetChild(2).GetComponent<Text>().text = moveAttens[i].pos;
  139. plan.GetChild(3).GetComponent<Text>().text = moveAttens[i].time;
  140. }
  141. }
  142. async Task InitBaseData() {
  143. bool successInternet = true;
  144. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeBaseData);
  145. await requestData.SendWebRequest();
  146. try
  147. {
  148. if (requestData.result != UnityWebRequest.Result.Success)
  149. {
  150. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返request不成功");
  151. successInternet = false;
  152. }
  153. else
  154. {
  155. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  156. JToken codeToken = jsonObject["code"];
  157. if (codeToken.ToString() == "200")
  158. {
  159. JToken areaToken = jsonObject["data"]["area"];
  160. JToken capacityToken = jsonObject["data"]["capacity"];
  161. JToken populationToken = jsonObject["data"]["population"];
  162. zYGKText[0].text = populationToken.ToString() + "人";
  163. zYGKText[1].text = GlobalData.allServerMovePlans.Count.ToString() + "条";
  164. zYGKText[2].text = areaToken.ToString() + "km²";
  165. zYGKText[3].text = (float.Parse((capacityToken.ToString())) * 100).ToString() + "%";
  166. }
  167. else
  168. {
  169. successInternet = false;
  170. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返序列化失败");
  171. }
  172. }
  173. }
  174. catch (Exception e)
  175. {
  176. successInternet = false;
  177. Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:" + e.ToString());
  178. }
  179. }
  180. async Task InitMovePlan() {
  181. zYYADatas = new ZYYAData[6] { new ZYYAData(), new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() };
  182. await new WaitUntil(() =>
  183. {
  184. return GlobalData.allServerMovePlans.Count > 0;
  185. });
  186. int beforeIndex = 0;
  187. int afterIndex = 0;
  188. List<LinePath> beforeLinePaths = new List<LinePath>();
  189. List<LinePath> afterLinePaths = new List<LinePath>();
  190. GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
  191. Transform runtimPointParent = shaPan.transform.GetChild(12);
  192. for (int i = 0; i < GlobalData.allServerMovePlans.Count; i++) {
  193. bool after = GlobalData.allServerMovePlans[i].isAfter;
  194. bool isOut = GlobalData.allServerMovePlans[i].isOut;
  195. if (!after)
  196. {
  197. LinePath lineParent = Instantiate(linePathPrefab);
  198. lineParent.transform.SetParent(beforeC);
  199. float clolorLerpUnit = 1.0f / (GlobalData.allServerMovePlans[i].paths.Count - 1);
  200. for (int j = 0; j < GlobalData.allServerMovePlans[i].paths.Count - 1; j++)
  201. {
  202. LinePathUnit linePath = Instantiate(linePathUnitPrefab);
  203. linePath.transform.SetParent(lineParent.transform);
  204. Vector3 localPos = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j].longitude, GlobalData.allServerMovePlans[i].paths[j].latitude);
  205. Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
  206. worldPos.z = -583;
  207. Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j + 1].longitude, GlobalData.allServerMovePlans[i].paths[j + 1].latitude);
  208. Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
  209. worldPos1.z = -583;
  210. linePath.SetPath(worldPos, worldPos1);
  211. linePath.SetColor(Color.Lerp(Color.yellow, Color.red, j * clolorLerpUnit), Color.Lerp(Color.yellow, Color.red, (j + 1) * clolorLerpUnit));
  212. if (j == 0)
  213. {
  214. RectTransform startSign = Instantiate(startPos);
  215. startSign.SetParent(pathSign);
  216. startSign.transform.localScale = Vector3.one;
  217. startSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
  218. startSign.GetComponent<PathSign>().bindPos = worldPos;
  219. }
  220. if (j == GlobalData.allServerMovePlans[i].paths.Count - 2)
  221. {
  222. RectTransform endSign = Instantiate(endPos);
  223. endSign.SetParent(pathSign);
  224. endSign.transform.localScale = Vector3.one;
  225. endSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
  226. endSign.GetComponent<PathSign>().bindPos = worldPos1;
  227. }
  228. }
  229. lineParent.startPos = GlobalData.allServerMovePlans[i].from;
  230. lineParent.endPos = GlobalData.allServerMovePlans[i].to;
  231. lineParent.lineDir = isOut ? LineDir.Out : LineDir.In;
  232. lineParent.linePathContent = GlobalData.allServerMovePlans[i].desc;
  233. lineParent.manNum = GlobalData.allServerMovePlans[i].manNum;
  234. lineParent.homeNum = GlobalData.allServerMovePlans[i].homeNum;
  235. lineParent.completeNum = GlobalData.allServerMovePlans[i].completeNum;
  236. lineParent.dateTime = GlobalData.allServerMovePlans[i].dateTime;
  237. if (lineParent.lineDir == LineDir.Out)
  238. {
  239. zYYADatas[1].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
  240. zYYADatas[1].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
  241. zYYADatas[1].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
  242. zYYADatas[1].totalRoadCount += 1;
  243. }
  244. else
  245. {
  246. zYYADatas[2].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
  247. zYYADatas[2].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
  248. zYYADatas[2].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
  249. zYYADatas[2].totalRoadCount += 1;
  250. }
  251. beforeLinePaths.Add(lineParent);
  252. }
  253. else
  254. {
  255. LinePath lineParent = Instantiate(linePathPrefab);
  256. lineParent.transform.SetParent(afterC);
  257. float clolorLerpUnit = 1.0f / (GlobalData.allServerMovePlans[i].paths.Count - 1);
  258. for (int j = 0; j < GlobalData.allServerMovePlans[i].paths.Count - 1; j++)
  259. {
  260. LinePathUnit linePath = Instantiate(linePathUnitPrefab);
  261. linePath.transform.SetParent(lineParent.transform);
  262. Vector3 localPos = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j].longitude, GlobalData.allServerMovePlans[i].paths[j].latitude);
  263. Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
  264. worldPos.z = -583;
  265. Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j + 1].longitude, GlobalData.allServerMovePlans[i].paths[j + 1].latitude);
  266. Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
  267. worldPos1.z = -583;
  268. linePath.SetPath(worldPos, worldPos1);
  269. linePath.SetColor(Color.Lerp(Color.yellow, Color.red, j * clolorLerpUnit), Color.Lerp(Color.yellow, Color.red, (j + 1) * clolorLerpUnit));
  270. if (j == 0)
  271. {
  272. RectTransform startSign = Instantiate(startPos);
  273. startSign.SetParent(pathSign);
  274. startSign.transform.localScale = Vector3.one;
  275. startSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
  276. startSign.GetComponent<PathSign>().bindPos = worldPos;
  277. }
  278. if (j == GlobalData.allServerMovePlans[i].paths.Count - 2)
  279. {
  280. RectTransform endSign = Instantiate(endPos);
  281. endSign.SetParent(pathSign);
  282. endSign.transform.localScale = Vector3.one;
  283. endSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
  284. endSign.GetComponent<PathSign>().bindPos = worldPos1;
  285. }
  286. }
  287. lineParent.startPos = GlobalData.allServerMovePlans[i].from;
  288. lineParent.endPos = GlobalData.allServerMovePlans[i].to;
  289. lineParent.lineDir = isOut ? LineDir.Out : LineDir.In;
  290. lineParent.linePathContent = GlobalData.allServerMovePlans[i].desc;
  291. lineParent.manNum = GlobalData.allServerMovePlans[i].manNum;
  292. lineParent.homeNum = GlobalData.allServerMovePlans[i].homeNum;
  293. lineParent.completeNum = GlobalData.allServerMovePlans[i].completeNum;
  294. lineParent.dateTime = GlobalData.allServerMovePlans[i].dateTime;
  295. if (lineParent.lineDir == LineDir.Out)
  296. {
  297. zYYADatas[4].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
  298. zYYADatas[4].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
  299. zYYADatas[4].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
  300. zYYADatas[4].totalRoadCount += 1;
  301. }
  302. else
  303. {
  304. zYYADatas[5].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
  305. zYYADatas[5].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
  306. zYYADatas[5].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
  307. zYYADatas[5].totalRoadCount += 1;
  308. }
  309. afterLinePaths.Add(lineParent);
  310. }
  311. zYYADatas[0].totalmanNum = zYYADatas[1].totalmanNum + zYYADatas[2].totalmanNum;
  312. zYYADatas[0].totalVillageCount = zYYADatas[1].totalVillageCount + zYYADatas[2].totalVillageCount;
  313. zYYADatas[0].totalMaterialPrize = zYYADatas[1].totalMaterialPrize + zYYADatas[2].totalMaterialPrize;
  314. zYYADatas[0].totalRoadCount = zYYADatas[1].totalRoadCount + zYYADatas[2].totalRoadCount;
  315. zYYADatas[3].totalmanNum = zYYADatas[4].totalmanNum + zYYADatas[5].totalmanNum;
  316. zYYADatas[3].totalVillageCount = zYYADatas[4].totalVillageCount + zYYADatas[5].totalVillageCount;
  317. zYYADatas[3].totalMaterialPrize = zYYADatas[4].totalMaterialPrize + zYYADatas[5].totalMaterialPrize;
  318. zYYADatas[3].totalRoadCount = zYYADatas[4].totalRoadCount + zYYADatas[5].totalRoadCount;
  319. RefreshZYYAData();
  320. }
  321. movePlans = new List<Thing1>();
  322. RectTransform title = Instantiate(title1);
  323. title.localScale = Vector3.one;
  324. title.SetParent(movePlanBeforeContent);
  325. RectTransform title2 = Instantiate(title1);
  326. title2.localScale = Vector3.one;
  327. title2.SetParent(movePlanAfterContent);
  328. List<ServerMovePlan> serverMovePlans = new List<ServerMovePlan>();
  329. for (int i = 0; i < beforeLinePaths.Count; i++)
  330. {
  331. int tempI = i;
  332. RectTransform plan = Instantiate(plan1);
  333. plan.SetParent(movePlanBeforeContent);
  334. Thing1 thing1 = plan.GetComponent<Thing1>();
  335. thing1.zyTime = ZYTime.Before;
  336. thing1.lineDir = beforeLinePaths[i].lineDir;
  337. thing1.bindLinePath = beforeLinePaths[i];
  338. thing1.GetComponent<Button>().onClick.AddListener(() =>
  339. {
  340. for (int i = 0; i < linePaths.Count; i++)
  341. {
  342. linePaths[i].gameObject.SetActive(false);
  343. }
  344. thing1.bindLinePath.gameObject.SetActive(true);
  345. });
  346. plan.localScale = Vector3.one;
  347. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  348. plan.GetChild(1).GetComponent<Text>().text = beforeLinePaths[i].startPos;
  349. plan.GetChild(2).GetComponent<Text>().text = beforeLinePaths[i].endPos;
  350. plan.GetChild(3).GetComponent<Text>().text = beforeLinePaths[i].manNum.ToString();
  351. plan.GetChild(4).GetComponent<Text>().text = beforeLinePaths[i].dateTime.ToString();
  352. movePlans.Add(thing1);
  353. }
  354. for (int i = 0; i < afterLinePaths.Count; i++)
  355. {
  356. RectTransform plan = Instantiate(plan1);
  357. plan.SetParent(movePlanAfterContent);
  358. Thing1 thing1 = plan.GetComponent<Thing1>();
  359. thing1.zyTime = ZYTime.After;
  360. thing1.lineDir = afterLinePaths[i].lineDir;
  361. thing1.bindLinePath = afterLinePaths[i];
  362. thing1.GetComponent<Button>().onClick.AddListener(() =>
  363. {
  364. for (int i = 0; i < linePaths.Count; i++)
  365. {
  366. linePaths[i].gameObject.SetActive(false);
  367. }
  368. thing1.bindLinePath.gameObject.SetActive(true);
  369. });
  370. plan.localScale = Vector3.one;
  371. plan.GetChild(0).GetComponent<Text>().text = i.ToString();
  372. plan.GetChild(1).GetComponent<Text>().text = afterLinePaths[i].startPos;
  373. plan.GetChild(2).GetComponent<Text>().text = afterLinePaths[i].endPos;
  374. plan.GetChild(3).GetComponent<Text>().text = afterLinePaths[i].manNum.ToString();
  375. plan.GetChild(4).GetComponent<Text>().text = afterLinePaths[i].dateTime.ToString();
  376. movePlans.Add(thing1);
  377. }
  378. movePlanAfterContent.gameObject.SetActive(false);
  379. }
  380. void ChangeLinePathChannel(int index) {
  381. switch (index)
  382. {
  383. case 0:
  384. for (int i = 0; i < linePaths.Count; i++)
  385. {
  386. linePaths[i].gameObject.SetActive(true);
  387. }
  388. break;
  389. case 1:
  390. for (int i = 0; i < linePaths.Count; i++)
  391. {
  392. if (linePaths[i].lineDir == LineDir.Out)
  393. linePaths[i].gameObject.SetActive(true);
  394. else
  395. linePaths[i].gameObject.SetActive(false);
  396. }
  397. break;
  398. case 2:
  399. for (int i = 0; i < linePaths.Count; i++)
  400. {
  401. if (linePaths[i].lineDir == LineDir.In)
  402. linePaths[i].gameObject.SetActive(true);
  403. else
  404. linePaths[i].gameObject.SetActive(false);
  405. }
  406. break;
  407. }
  408. }
  409. void RefreshZYYAData() {
  410. zYYAIndex = beforeAfterIndex * 3 + inOutIndex;
  411. zYYAText[0].text = zYYADatas[zYYAIndex].totalVillageCount.ToString();
  412. zYYAText[1].text = (zYYADatas[zYYAIndex].totalmanNum / 10000.0f).ToString("0.00");
  413. zYYAText[2].text = (zYYADatas[zYYAIndex].totalMaterialPrize / 100000000.0f).ToString("0.00");
  414. zYYAText[3].text = zYYADatas[zYYAIndex].totalRoadCount.ToString();
  415. }
  416. void BeforeBtnClick() {
  417. beforeAfterIndex = 0;
  418. beforeBtn.GetComponent<Image>().sprite = sprites[0];
  419. afterBtn.GetComponent<Image>().sprite = sprites[1];
  420. beforeC.gameObject.SetActive(true);
  421. afterC.gameObject.SetActive(false);
  422. movePlanBeforeContent.gameObject.SetActive(true);
  423. movePlanAfterContent.gameObject.SetActive(false);
  424. ChangeLinePathChannel(inOutIndex);
  425. RefreshZYYAData();
  426. }
  427. void AfterBtnClick()
  428. {
  429. beforeAfterIndex = 1;
  430. beforeBtn.GetComponent<Image>().sprite = sprites[1];
  431. afterBtn.GetComponent<Image>().sprite = sprites[0];
  432. beforeC.gameObject.SetActive(false);
  433. afterC.gameObject.SetActive(true);
  434. movePlanBeforeContent.gameObject.SetActive(false);
  435. movePlanAfterContent.gameObject.SetActive(true);
  436. ChangeLinePathChannel(inOutIndex);
  437. RefreshZYYAData();
  438. }
  439. void InitButton() {
  440. beforeBtn.onClick.AddListener(() => {
  441. BeforeBtnClick();
  442. });
  443. afterBtn.onClick.AddListener(() => {
  444. AfterBtnClick();
  445. });
  446. allInOut[0].onClick.AddListener(() =>
  447. {
  448. inOutIndex = 0;
  449. ChangeLinePathChannel(0);
  450. for (int i = 0; i < movePlans.Count; i++)
  451. {
  452. movePlans[i].gameObject.SetActive(true);
  453. }
  454. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[0];
  455. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
  456. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
  457. RefreshZYYAData();
  458. });
  459. allInOut[1].onClick.AddListener(() =>
  460. {
  461. inOutIndex = 1;
  462. ChangeLinePathChannel(1);
  463. for (int i = 0; i < movePlans.Count; i++)
  464. {
  465. if (movePlans[i].lineDir == LineDir.Out)
  466. movePlans[i].gameObject.SetActive(true);
  467. else
  468. movePlans[i].gameObject.SetActive(false);
  469. }
  470. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
  471. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[0];
  472. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
  473. RefreshZYYAData();
  474. });
  475. allInOut[2].onClick.AddListener(() =>
  476. {
  477. inOutIndex = 2;
  478. ChangeLinePathChannel(2);
  479. for (int i = 0; i < movePlans.Count; i++)
  480. {
  481. if (movePlans[i].lineDir == LineDir.In)
  482. movePlans[i].gameObject.SetActive(true);
  483. else
  484. movePlans[i].gameObject.SetActive(false);
  485. }
  486. allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
  487. allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
  488. allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[0];
  489. RefreshZYYAData();
  490. });
  491. BeforeBtnClick();
  492. }
  493. void InitAllPath() {
  494. for (int i = 0; i < beforeC.childCount; i++)
  495. {
  496. if (beforeC.GetChild(i).GetComponent<LinePath>())
  497. {
  498. linePaths.Add(beforeC.GetChild(i).GetComponent<LinePath>());
  499. }
  500. }
  501. for (int i = 0; i < afterC.childCount; i++)
  502. {
  503. if (afterC.GetChild(i).GetComponent<LinePath>())
  504. {
  505. linePaths.Add(afterC.GetChild(i).GetComponent<LinePath>());
  506. }
  507. }
  508. }
  509. // Update is called once per frame
  510. void Update()
  511. {
  512. // 获取当前时间
  513. DateTime now = DateTime.Now;
  514. // 格式化时间字符串
  515. string timeString = now.ToString("yyyy/MM/dd HH:mm");
  516. // 将格式化的时间字符串设置到UI Text组件上
  517. timeText.text = timeString;
  518. }
  519. LinePath lastPath;
  520. private void FixedUpdate()
  521. {
  522. if (lineInfo.linePaths.Count > 0)
  523. {
  524. lineInfo.gameObject.SetActive(true);
  525. }
  526. else
  527. {
  528. lineInfo.gameObject.SetActive(false);
  529. }
  530. Ray ray = CameraManager.instance.secondCamera.ScreenPointToRay(Input.mousePosition);
  531. RaycastHit hit;
  532. if (Physics.Raycast(ray, out hit, 10000))
  533. {
  534. Debug.Log(hit.collider.gameObject.name);
  535. // 检查射线是否击中 LineRenderer 所在的物体
  536. if (hit.collider.transform.parent.parent.GetComponent<LinePath>() != null)
  537. {
  538. if (lastPath != null && hit.collider.transform.parent.parent.GetComponent<LinePath>() != lastPath) {
  539. lastPath.UnShow();
  540. }
  541. hit.collider.transform.parent.parent.GetComponent<LinePath>().OnShow();
  542. lastPath = hit.collider.transform.parent.parent.GetComponent<LinePath>();
  543. }
  544. else
  545. {
  546. if (lastPath)
  547. {
  548. lastPath.UnShow();
  549. lastPath = null;
  550. }
  551. }
  552. }
  553. else {
  554. if (lastPath)
  555. {
  556. lastPath.UnShow();
  557. lastPath = null;
  558. }
  559. }
  560. }
  561. }