123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798 |
- using Best.HTTP.Shared.Compression.Zlib;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using Unity.VisualScripting;
- using UnityAsync;
- using UnityEngine;
- using UnityEngine.Networking;
- using UnityEngine.UI;
- using Color = UnityEngine.Color;
- using WaitUntil = UnityAsync.WaitUntil;
- [System.Serializable]
- public class MovePlan
- {
- public string startPos;
- public string endPos;
- public int humanNum;
- public string time;
- }
- [System.Serializable]
- public class MoveAtten
- {
- public string title;
- public string pos;
- public string time;
- }
- [System.Serializable]
- public class MovePath
- {
- public MovePath(double l1, double l2)
- {
- longitude = l1;
- latitude = l2;
- }
- public double longitude;
- public double latitude;
- }
- [System.Serializable]
- public class ServerMovePlan {
- public bool isAfter;
- public bool isOut;
- public string desc;
- public string from;
- public float fromLong;
- public float fromLttd;
- public string to;
- public float toLong;
- public float toLttd;
- public int manNum;
- public int homeNum;
- public int completeNum;
- public string dateTime;
- public int villageCount;
- public int materialPrize;
- public List<MovePath> paths = new List<MovePath>();
- }
- [System.Serializable]
- public class ZYYAData
- {
- public int totalRoadCount;
- public float totalmanNum;
- public int totalVillageCount;
- public float totalMaterialPrize;
- }
- public class RKZYLayer : YZTRootLayer
- {
- public static float lineOrderZ = 0.01f;
- public Text timeText;
- public LineInfo lineInfo;
- //public List<MovePlan> movePlans;
- public List<Thing1> movePlans;
- public List<MoveAtten> moveAttens;
- public static LineInfo lineInfoStatic;
- public Button beforeBtn;
- public Button afterBtn;
- public Button[] allInOut;
- public Transform beforeC;
- public Transform afterC;
- public List<LinePath> linePaths = new List<LinePath>();
- public Sprite[] sprites;
- public int inOutIndex;
- public int beforeAfterIndex;
- public RectTransform title1;
- public RectTransform plan1;
- public RectTransform movePlanBeforeContent;
- public RectTransform movePlanAfterContent;
- public RectTransform title2;
- public RectTransform plan2;
- public RectTransform attenContent;
-
- public Text[] zYGKText;
- public ZYYAData[] zYYADatas;
- public int zYYAIndex = 0;
- public Text[] zYYAText;
- public Material afterMat;
- public LinePathUnit linePathUnitPrefab;
- public LinePath linePathPrefab;
- public RectTransform startPos;
- public RectTransform endPos;
- public RectTransform pathSign;
- public int page = 0;
- public List<Thing1> allFilterPlans = new List<Thing1>();
- [Header("计算面板和三个新加的按钮")]
- public GameObject calculatePanel;
- public Button closeCalculateButton;
- public Text lineNameText;
- public Text lineStarToEndText;
- public InputField peopleCountText;
- public InputField tunTuText;
- public InputField zhuangZaiText;
- public InputField moveTimeText;
- public Button allLineButton;
- public Button calculateShowButton;
- public Button showMoveButton;
- public GameObject calcMask;
- public Button calcTimeBtn;
- public Button resetTimeBtn;
- private bool calcOpen = true;
- public InputField searchPath;
- public Thing1 currentPath;
- // Start is called before the first frame update
- async void Start()
- {
- GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
- beforeC.gameObject.SetActive(true);
- beforeC = shaPan.transform.GetChild(12);
- afterC = shaPan.transform.GetChild(13);
- lineInfoStatic = lineInfo;
- await InitMovePlan();
- //TODO 这一块的path应该从movePlan里面生成而不是默认
- InitAllPath();
- InitButton();
- InitAtten();
- await InitBaseData();
- }
- public override void OnUILeave()
- {
- base.OnUILeave();
- beforeC.gameObject.SetActive(false);
- afterC.gameObject.SetActive(false);
- }
- private void OnEnable()
- {
- CameraManager.SwitchCamera(1);
- if(page == 0)
- beforeC.gameObject.SetActive(true);
- else
- afterC.gameObject.SetActive(true);
- }
- void InitAtten() {
- RectTransform title = Instantiate(title2);
- title.SetParent(attenContent);
- title.localScale = Vector3.one;
- for (int i = 0; i < moveAttens.Count; i++)
- {
- RectTransform plan = Instantiate(plan2);
- plan.SetParent(attenContent);
- plan.localScale = Vector3.one;
- plan.GetChild(0).GetComponent<Text>().text = i.ToString();
- plan.GetChild(1).GetComponent<Text>().text = moveAttens[i].title;
- plan.GetChild(2).GetComponent<Text>().text = moveAttens[i].pos;
- plan.GetChild(3).GetComponent<Text>().text = moveAttens[i].time;
- }
- }
- async Task InitBaseData() {
- bool successInternet = true;
- UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeBaseData);
- await requestData.SendWebRequest();
- try
- {
- if (requestData.result != UnityWebRequest.Result.Success)
- {
- Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返request不成功");
- successInternet = false;
- }
- else
- {
- JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
- JToken codeToken = jsonObject["code"];
- if (codeToken.ToString() == "200")
- {
- JToken areaToken = jsonObject["data"]["area"];
- JToken capacityToken = jsonObject["data"]["capacity"];
- JToken populationToken = jsonObject["data"]["population"];
- zYGKText[0].text = populationToken.ToString() + "人";
- zYGKText[1].text = GlobalData.allServerMovePlans.Count.ToString() + "条";
- zYGKText[2].text = areaToken.ToString() + "km²";
- zYGKText[3].text = (float.Parse((capacityToken.ToString())) * 100).ToString() + "%";
- }
- else
- {
- successInternet = false;
- Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:返序列化失败");
- }
- }
- }
- catch (Exception e)
- {
- successInternet = false;
- Debug.LogWarning("RKZYLayer基础数据联网不成功,原因:" + e.ToString());
- }
- }
- async Task InitMovePlan() {
-
- zYYADatas = new ZYYAData[6] { new ZYYAData(), new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() , new ZYYAData() };
- await new WaitUntil(() =>
- {
- return GlobalData.allServerMovePlans.Count > 0;
- });
- int beforeIndex = 0;
- int afterIndex = 0;
- List<LinePath> beforeLinePaths = new List<LinePath>();
- List<LinePath> afterLinePaths = new List<LinePath>();
- GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
- Transform runtimPointParent = shaPan.transform.GetChild(12);
- for (int i = 0; i < GlobalData.allServerMovePlans.Count; i++) {
- bool after = GlobalData.allServerMovePlans[i].isAfter;
- bool isOut = GlobalData.allServerMovePlans[i].isOut;
- if (!after)
- {
- LinePath lineParent = Instantiate(linePathPrefab);
- lineParent.transform.SetParent(beforeC);
- float clolorLerpUnit = 1.0f / (GlobalData.allServerMovePlans[i].paths.Count - 1);
- for (int j = 0; j < GlobalData.allServerMovePlans[i].paths.Count - 1; j++)
- {
- LinePathUnit linePath = Instantiate(linePathUnitPrefab);
- linePath.transform.SetParent(lineParent.transform);
-
- Vector3 localPos = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j].longitude, GlobalData.allServerMovePlans[i].paths[j].latitude);
- Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
- worldPos.z = -583;
-
- Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j + 1].longitude, GlobalData.allServerMovePlans[i].paths[j + 1].latitude);
- Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
- worldPos1.z = -583;
- linePath.SetPath(worldPos, worldPos1);
- linePath.SetColor(Color.Lerp(Color.yellow, Color.red, j * clolorLerpUnit), Color.Lerp(Color.yellow, Color.red, (j + 1) * clolorLerpUnit));
- if (j == 0)
- {
- RectTransform startSign = Instantiate(startPos);
- startSign.SetParent(pathSign);
- startSign.transform.localScale = Vector3.one;
- startSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
- startSign.GetComponent<PathSign>().bindPos = worldPos;
- }
- if (j == GlobalData.allServerMovePlans[i].paths.Count - 2)
- {
- RectTransform endSign = Instantiate(endPos);
- endSign.SetParent(pathSign);
- endSign.transform.localScale = Vector3.one;
- endSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
- endSign.GetComponent<PathSign>().bindPos = worldPos1;
- }
- }
- lineParent.startPos = GlobalData.allServerMovePlans[i].from;
- lineParent.endPos = GlobalData.allServerMovePlans[i].to;
- lineParent.lineDir = isOut ? LineDir.Out : LineDir.In;
- lineParent.linePathContent = GlobalData.allServerMovePlans[i].desc;
- lineParent.manNum = GlobalData.allServerMovePlans[i].manNum;
- lineParent.homeNum = GlobalData.allServerMovePlans[i].homeNum;
- lineParent.completeNum = GlobalData.allServerMovePlans[i].completeNum;
- lineParent.dateTime = GlobalData.allServerMovePlans[i].dateTime;
- lineParent.xishu = UnityEngine.Random.Range(10f, 30.0f);
- if (lineParent.lineDir == LineDir.Out)
- {
- zYYADatas[1].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
- zYYADatas[1].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
- zYYADatas[1].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
- zYYADatas[1].totalRoadCount += 1;
- }
- else
- {
- zYYADatas[2].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
- zYYADatas[2].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
- zYYADatas[2].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
- zYYADatas[2].totalRoadCount += 1;
- }
- lineParent.transform.localPosition = new Vector3(lineParent.transform.localPosition.x, lineParent.transform.localPosition.y, lineOrderZ);
- lineOrderZ += 0.01f;
- beforeLinePaths.Add(lineParent);
-
- }
- else
- {
- LinePath lineParent = Instantiate(linePathPrefab);
- lineParent.transform.SetParent(afterC);
- float clolorLerpUnit = 1.0f / (GlobalData.allServerMovePlans[i].paths.Count - 1);
- for (int j = 0; j < GlobalData.allServerMovePlans[i].paths.Count - 1; j++)
- {
- LinePathUnit linePath = Instantiate(linePathUnitPrefab);
- linePath.transform.SetParent(lineParent.transform);
- Vector3 localPos = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j].longitude, GlobalData.allServerMovePlans[i].paths[j].latitude);
- Vector3 worldPos = runtimPointParent.TransformPoint(localPos);
- worldPos.z = -583;
- Vector3 localPos1 = CoordinateConverter.GeoToUGUISmall(GlobalData.allServerMovePlans[i].paths[j + 1].longitude, GlobalData.allServerMovePlans[i].paths[j + 1].latitude);
- Vector3 worldPos1 = runtimPointParent.TransformPoint(localPos1);
- worldPos1.z = -583;
- linePath.SetPath(worldPos, worldPos1);
- linePath.SetColor(Color.Lerp(Color.yellow, Color.red, j * clolorLerpUnit), Color.Lerp(Color.yellow, Color.red, (j + 1) * clolorLerpUnit));
- if (j == 0)
- {
- RectTransform startSign = Instantiate(startPos);
- startSign.SetParent(pathSign);
- startSign.transform.localScale = Vector3.one;
- startSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
- startSign.GetComponent<PathSign>().bindPos = worldPos;
- }
- if (j == GlobalData.allServerMovePlans[i].paths.Count - 2)
- {
- RectTransform endSign = Instantiate(endPos);
- endSign.SetParent(pathSign);
- endSign.transform.localScale = Vector3.one;
- endSign.GetComponent<PathSign>().bindObj = linePath.gameObject;
- endSign.GetComponent<PathSign>().bindPos = worldPos1;
- }
- }
- lineParent.startPos = GlobalData.allServerMovePlans[i].from;
- lineParent.endPos = GlobalData.allServerMovePlans[i].to;
- lineParent.lineDir = isOut ? LineDir.Out : LineDir.In;
- lineParent.linePathContent = GlobalData.allServerMovePlans[i].desc;
- lineParent.manNum = GlobalData.allServerMovePlans[i].manNum;
- lineParent.homeNum = GlobalData.allServerMovePlans[i].homeNum;
- lineParent.completeNum = GlobalData.allServerMovePlans[i].completeNum;
- lineParent.dateTime = GlobalData.allServerMovePlans[i].dateTime;
- lineParent.xishu = UnityEngine.Random.Range(10f, 30.0f);
- if (lineParent.lineDir == LineDir.Out)
- {
- zYYADatas[4].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
- zYYADatas[4].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
- zYYADatas[4].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
- zYYADatas[4].totalRoadCount += 1;
- }
- else
- {
- zYYADatas[5].totalmanNum += GlobalData.allServerMovePlans[i].manNum;
- zYYADatas[5].totalVillageCount += GlobalData.allServerMovePlans[i].villageCount;
- zYYADatas[5].totalMaterialPrize += GlobalData.allServerMovePlans[i].materialPrize;
- zYYADatas[5].totalRoadCount += 1;
- }
- lineParent.transform.localPosition = new Vector3(lineParent.transform.localPosition.x, lineParent.transform.localPosition.y, lineOrderZ);
- lineOrderZ += 0.01f;
- afterLinePaths.Add(lineParent);
- }
- zYYADatas[0].totalmanNum = zYYADatas[1].totalmanNum + zYYADatas[2].totalmanNum;
- zYYADatas[0].totalVillageCount = zYYADatas[1].totalVillageCount + zYYADatas[2].totalVillageCount;
- zYYADatas[0].totalMaterialPrize = zYYADatas[1].totalMaterialPrize + zYYADatas[2].totalMaterialPrize;
- zYYADatas[0].totalRoadCount = zYYADatas[1].totalRoadCount + zYYADatas[2].totalRoadCount;
- zYYADatas[3].totalmanNum = zYYADatas[4].totalmanNum + zYYADatas[5].totalmanNum;
- zYYADatas[3].totalVillageCount = zYYADatas[4].totalVillageCount + zYYADatas[5].totalVillageCount;
- zYYADatas[3].totalMaterialPrize = zYYADatas[4].totalMaterialPrize + zYYADatas[5].totalMaterialPrize;
- zYYADatas[3].totalRoadCount = zYYADatas[4].totalRoadCount + zYYADatas[5].totalRoadCount;
- RefreshZYYAData();
- }
-
- movePlans = new List<Thing1>();
- RectTransform title = Instantiate(title1);
- title.localScale = Vector3.one;
- title.SetParent(movePlanBeforeContent);
- RectTransform title2 = Instantiate(title1);
- title2.localScale = Vector3.one;
- title2.SetParent(movePlanAfterContent);
- List<ServerMovePlan> serverMovePlans = new List<ServerMovePlan>();
- for (int i = 0; i < beforeLinePaths.Count; i++)
- {
- int tempI = i;
- RectTransform plan = Instantiate(plan1);
- plan.SetParent(movePlanBeforeContent);
- Thing1 thing1 = plan.GetComponent<Thing1>();
- thing1.zyTime = ZYTime.Before;
- thing1.lineDir = beforeLinePaths[i].lineDir;
- thing1.bindLinePath = beforeLinePaths[i];
- thing1.GetComponent<Button>().onClick.AddListener(() =>
- {
- for (int i = 0; i < linePaths.Count; i++)
- {
- linePaths[i].gameObject.SetActive(false);
- }
- thing1.bindLinePath.gameObject.SetActive(true);
- CheckCalcUsable(thing1);
- });
- plan.localScale = Vector3.one;
- plan.GetChild(0).GetComponent<Text>().text = i.ToString();
- plan.GetChild(1).GetComponent<Text>().text = beforeLinePaths[i].startPos;
- plan.GetChild(2).GetComponent<Text>().text = beforeLinePaths[i].endPos;
- plan.GetChild(3).GetComponent<Text>().text = beforeLinePaths[i].manNum.ToString();
- plan.GetChild(4).GetComponent<Text>().text = beforeLinePaths[i].dateTime.ToString();
- movePlans.Add(thing1);
-
- }
- for (int i = 0; i < afterLinePaths.Count; i++)
- {
- RectTransform plan = Instantiate(plan1);
- plan.SetParent(movePlanAfterContent);
- Thing1 thing1 = plan.GetComponent<Thing1>();
- thing1.zyTime = ZYTime.After;
- thing1.lineDir = afterLinePaths[i].lineDir;
- thing1.bindLinePath = afterLinePaths[i];
- thing1.GetComponent<Button>().onClick.AddListener(() =>
- {
- for (int i = 0; i < linePaths.Count; i++)
- {
- linePaths[i].gameObject.SetActive(false);
- }
- thing1.bindLinePath.gameObject.SetActive(true);
- CheckCalcUsable(thing1);
- });
- plan.localScale = Vector3.one;
- plan.GetChild(0).GetComponent<Text>().text = i.ToString();
- plan.GetChild(1).GetComponent<Text>().text = afterLinePaths[i].startPos;
- plan.GetChild(2).GetComponent<Text>().text = afterLinePaths[i].endPos;
- plan.GetChild(3).GetComponent<Text>().text = afterLinePaths[i].manNum.ToString();
- plan.GetChild(4).GetComponent<Text>().text = afterLinePaths[i].dateTime.ToString();
- movePlans.Add(thing1);
- }
- movePlanAfterContent.gameObject.SetActive(false);
-
- }
- void CheckCalcUsable(Thing1 thing1 = null) {
- currentPath = thing1;
- if (currentPath != null)
- {
- calcMask.gameObject.SetActive(false);
- peopleCountText.text = currentPath.bindLinePath.manNum.ToString();
- lineNameText.text = currentPath.bindLinePath.lineDir == LineDir.In ? "内转安置" : "外传安置";
- lineStarToEndText.text = currentPath.bindLinePath.startPos + "→ " + currentPath.bindLinePath.endPos;
- moveTimeText.text = "待计算";
- tunTuText.text = currentPath.bindLinePath.xishu.ToString();
- }
- else {
- calcMask.gameObject.SetActive(true);
- }
- }
- void ChangeLinePathChannel(int index) {
- switch (index)
- {
- case 0:
- for (int i = 0; i < linePaths.Count; i++)
- {
- linePaths[i].gameObject.SetActive(true);
- }
- break;
- case 1:
- for (int i = 0; i < linePaths.Count; i++)
- {
- if (linePaths[i].lineDir == LineDir.Out)
- linePaths[i].gameObject.SetActive(true);
- else
- linePaths[i].gameObject.SetActive(false);
- }
- break;
- case 2:
- for (int i = 0; i < linePaths.Count; i++)
- {
- if (linePaths[i].lineDir == LineDir.In)
- linePaths[i].gameObject.SetActive(true);
- else
- linePaths[i].gameObject.SetActive(false);
- }
- break;
- }
- }
- void RefreshZYYAData() {
- zYYAIndex = beforeAfterIndex * 3 + inOutIndex;
- zYYAText[0].text = zYYADatas[zYYAIndex].totalVillageCount.ToString();
- zYYAText[1].text = (zYYADatas[zYYAIndex].totalmanNum / 10000.0f).ToString("0.00");
- zYYAText[2].text = (zYYADatas[zYYAIndex].totalMaterialPrize / 100000000.0f).ToString("0.00");
- zYYAText[3].text = zYYADatas[zYYAIndex].totalRoadCount.ToString();
- }
- void BeforeBtnClick() {
- beforeAfterIndex = 0;
- beforeBtn.GetComponent<Image>().sprite = sprites[0];
- afterBtn.GetComponent<Image>().sprite = sprites[1];
- beforeC.gameObject.SetActive(true);
- afterC.gameObject.SetActive(false);
- movePlanBeforeContent.gameObject.SetActive(true);
- movePlanAfterContent.gameObject.SetActive(false);
- ChangeLinePathChannel(inOutIndex);
- RefreshZYYAData();
- page = 0;
- }
- void AfterBtnClick()
- {
- beforeAfterIndex = 1;
- beforeBtn.GetComponent<Image>().sprite = sprites[1];
- afterBtn.GetComponent<Image>().sprite = sprites[0];
- beforeC.gameObject.SetActive(false);
- afterC.gameObject.SetActive(true);
- movePlanBeforeContent.gameObject.SetActive(false);
- movePlanAfterContent.gameObject.SetActive(true);
- ChangeLinePathChannel(inOutIndex);
- RefreshZYYAData();
- page = 1;
- }
- void InitButton() {
- beforeBtn.onClick.AddListener(() => {
- BeforeBtnClick();
- });
- afterBtn.onClick.AddListener(() => {
- AfterBtnClick();
- });
- allLineButton.onClick.AddListener(() =>
- {
- ChangeLinePathChannel(inOutIndex);
- CheckCalcUsable();
- });
- calculateShowButton.onClick.AddListener(() =>
- {
- calcOpen = !calcOpen;
- if (calcOpen)
- {
- calculateShowButton.GetComponent<Image>().color = new UnityEngine.Color(1, 1, 1, 1f);
- calculatePanel.gameObject.SetActive(true);
- }
- else {
- calculateShowButton.GetComponent<Image>().color = new UnityEngine.Color(1, 1, 1, 0.5f);
- calculatePanel.gameObject.SetActive(false);
- }
- });
- searchPath.onValueChanged.AddListener((string searchItem) =>
- {
- allFilterPlans.Clear();
- for (int i = 0; i < movePlans.Count; i++)
- {
- if ((int)movePlans[i].bindLinePath.lineDir + 1 == inOutIndex || inOutIndex == 0)
- {
- if (searchItem.Trim().Length < 1)
- {
- movePlans[i].gameObject.SetActive(true);
- }
- else {
- if (movePlans[i].bindLinePath.startPos.Contains(searchItem) || movePlans[i].bindLinePath.endPos.Contains(searchItem))
- {
- movePlans[i].gameObject.SetActive(true);
- }
- else {
- movePlans[i].gameObject.SetActive(false);
- }
- }
- }
- else {
- movePlans[i].gameObject.SetActive(false);
- }
- }
- });
- calcTimeBtn.onClick.AddListener(() =>
- {
- int manNum = 1;
- int zzManNum = 1;
- float tuntu = 0;
- if (peopleCountText.text.Trim().Length < 1 || zhuangZaiText.text.Trim().Length < 1)
- {
- moveTimeText.text = "请输入数据";
- moveTimeText.transform.GetChild(2).GetComponent<Text>().color = Color.red;
- }
- else if (!int.TryParse(peopleCountText.text,out manNum) || !int.TryParse(zhuangZaiText.text, out zzManNum) ||
- !float.TryParse(tunTuText.text, out tuntu))
- {
- moveTimeText.text = "请检查数据";
- moveTimeText.transform.GetChild(2).GetComponent<Text>().color = Color.red;
- }
- else
- {
- moveTimeText.text = (manNum / tuntu / zzManNum).ToString("0.0") + "小时";
- moveTimeText.transform.GetChild(2).GetComponent<Text>().color = Color.white;
- }
- });
- resetTimeBtn.onClick.AddListener(() =>
- {
- peopleCountText.text = "";
- zhuangZaiText.text = "";
- moveTimeText.text = "待计算";
- });
- closeCalculateButton.onClick.AddListener(() =>
- {
- calculatePanel.gameObject.SetActive(false);
- calculateShowButton.GetComponent<Image>().color = new UnityEngine.Color(1, 1, 1, 0.5f);
- calcOpen = false;
- });
- allInOut[0].onClick.AddListener(() =>
- {
- inOutIndex = 0;
- ChangeLinePathChannel(0);
- for (int i = 0; i < movePlans.Count; i++)
- {
- movePlans[i].gameObject.SetActive(true);
- }
- allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[0];
- allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
- allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
- RefreshZYYAData();
- CheckCalcUsable();
- });
- allInOut[1].onClick.AddListener(() =>
- {
- inOutIndex = 1;
- ChangeLinePathChannel(1);
- for (int i = 0; i < movePlans.Count; i++)
- {
- if (movePlans[i].lineDir == LineDir.Out)
- {
- movePlans[i].gameObject.SetActive(true);
- }
- else
- movePlans[i].gameObject.SetActive(false);
- }
- allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
- allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[0];
- allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[1];
- RefreshZYYAData();
- CheckCalcUsable();
- });
- allInOut[2].onClick.AddListener(() =>
- {
- inOutIndex = 2;
- ChangeLinePathChannel(2);
- for (int i = 0; i < movePlans.Count; i++)
- {
- if (movePlans[i].lineDir == LineDir.In)
- {
- movePlans[i].gameObject.SetActive(true);
- }
- else
- movePlans[i].gameObject.SetActive(false);
- }
- allInOut[0].gameObject.GetComponent<Image>().sprite = sprites[1];
- allInOut[1].gameObject.GetComponent<Image>().sprite = sprites[1];
- allInOut[2].gameObject.GetComponent<Image>().sprite = sprites[0];
- RefreshZYYAData();
- CheckCalcUsable();
- });
- BeforeBtnClick();
- }
- void InitAllPath() {
- for (int i = 0; i < beforeC.childCount; i++)
- {
- if (beforeC.GetChild(i).GetComponent<LinePath>())
- {
- linePaths.Add(beforeC.GetChild(i).GetComponent<LinePath>());
- }
- }
- for (int i = 0; i < afterC.childCount; i++)
- {
- if (afterC.GetChild(i).GetComponent<LinePath>())
- {
- linePaths.Add(afterC.GetChild(i).GetComponent<LinePath>());
- }
- }
- }
- // Update is called once per frame
- void Update()
- {
- // 获取当前时间
- DateTime now = DateTime.Now;
- // 格式化时间字符串
- string timeString = now.ToString("yyyy/MM/dd HH:mm");
- // 将格式化的时间字符串设置到UI Text组件上
- timeText.text = timeString;
- }
- LinePath lastPath;
- private void FixedUpdate()
- {
- if (lineInfo.linePaths.Count > 0)
- {
- lineInfo.gameObject.SetActive(true);
- }
- else
- {
- lineInfo.gameObject.SetActive(false);
- }
- Ray ray = CameraManager.instance.secondCamera.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 10000))
- {
- Debug.Log(hit.collider.gameObject.name);
- // 检查射线是否击中 LineRenderer 所在的物体
- if (hit.collider.transform.parent.parent.GetComponent<LinePath>() != null)
- {
- if (lastPath != null && hit.collider.transform.parent.parent.GetComponent<LinePath>() != lastPath) {
- lastPath.UnShow();
- }
- hit.collider.transform.parent.parent.GetComponent<LinePath>().OnShow();
- lastPath = hit.collider.transform.parent.parent.GetComponent<LinePath>();
- }
- else
- {
- if (lastPath)
- {
- lastPath.UnShow();
- lastPath = null;
- }
- }
- }
- else {
- if (lastPath)
- {
- lastPath.UnShow();
- lastPath = null;
- }
- }
- }
-
- }
|