Browse Source

Merge branch 'main' of http://www.chatgpt918.top:3000/wartheking/WaterFlush

SunZhi 7 months ago
parent
commit
bde8f01259
2 changed files with 222 additions and 66 deletions
  1. 97 0
      Assets/Scene 1.unity
  2. 125 66
      Assets/Scripts/UI/UIView/YZT/YZTLayer.cs

File diff suppressed because it is too large
+ 97 - 0
Assets/Scene 1.unity


+ 125 - 66
Assets/Scripts/UI/UIView/YZT/YZTLayer.cs

@@ -115,7 +115,7 @@ public class YZTLayer : YZTRootLayer
     public GameObject yZTMini;
     public GameObject yZT;
 
-   
+
     public RectTransform infoRight;
 
     public Button returnBtn;
@@ -158,7 +158,7 @@ public class YZTLayer : YZTRootLayer
     // Start is called before the first frame update
 
     public WaterTrendPanel _waterTrendPanel;
-    
+
     async void Awake()
     {
         viewMode = ViewMode.miniMap;
@@ -174,11 +174,13 @@ public class YZTLayer : YZTRootLayer
         InitSWHeightInfo();
         await InitPointData();
         InitPoint();
-        
+
     }
 
-    void InitLeftBtn() {
-        for (int i = 0; i < leftButtons.Length; i++) {
+    void InitLeftBtn()
+    {
+        for (int i = 0; i < leftButtons.Length; i++)
+        {
             int temp = i;
             leftButtons[i].onClick.AddListener(() =>
             {
@@ -187,7 +189,8 @@ public class YZTLayer : YZTRootLayer
         }
         LeftBtnClick(0);
 
-        clearBtn.onClick.AddListener(() => {
+        clearBtn.onClick.AddListener(() =>
+        {
             if (clearBtn.GetComponent<Image>().sprite == sprites[0])
             {
                 clearBtn.GetComponent<Image>().sprite = sprites[1];
@@ -197,7 +200,8 @@ public class YZTLayer : YZTRootLayer
                 rightContent.gameObject.SetActive(false);
                 clearBtn.GetComponent<RectTransform>().anchoredPosition = new Vector2(-827, clearBtn.GetComponent<RectTransform>().anchoredPosition.y);
             }
-            else {
+            else
+            {
                 clearBtn.GetComponent<Image>().sprite = sprites[0];
                 leftContent.gameObject.SetActive(true);
                 pointParent.gameObject.SetActive(true);
@@ -205,21 +209,24 @@ public class YZTLayer : YZTRootLayer
                 rightContent.gameObject.SetActive(true);
                 clearBtn.GetComponent<RectTransform>().anchoredPosition = new Vector2(-457, clearBtn.GetComponent<RectTransform>().anchoredPosition.y);
             }
-            
+
         });
     }
 
-    async void InitSWHeightInfo() {
-        await new WaitUntil(() => {
+    async void InitSWHeightInfo()
+    {
+        await new WaitUntil(() =>
+        {
             return GlobalData.swDatas.Count > 0;
         });
         if (rescordSWStationData.Count < 1)
         {
-            for (int i = 0; i < GlobalData.swDatas.Count; i++) {
+            for (int i = 0; i < GlobalData.swDatas.Count; i++)
+            {
                 SWStationRecordData sWStationRecordData = new SWStationRecordData();
                 sWStationRecordData.dir = 0;
                 sWStationRecordData.name = GlobalData.swDatas[i].STNM;
-                sWStationRecordData.value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz)?GlobalData.swDatas[i].upz:GlobalData.swDatas[i].dwz;
+                sWStationRecordData.value = (GlobalData.swDatas[i].upz > GlobalData.swDatas[i].dwz) ? GlobalData.swDatas[i].upz : GlobalData.swDatas[i].dwz;
                 sWStationRecordData.time = DateTime.Now.ToString("MM/dd HH:mm");
                 sWStationRecordData.stcd = GlobalData.swDatas[i].STCD;
                 rescordSWStationData.Add(sWStationRecordData);
@@ -231,14 +238,14 @@ public class YZTLayer : YZTRootLayer
                 obj.GetComponent<RectTransform>().SetParent(thingParent);
                 obj.transform.localScale = Vector3.one;
                 obj.transform.GetChild(0).GetComponent<Text>().text = (i + 1).ToString();
-                string rescordSW_name= rescordSWStationData[i].name.ToString();;
+                string rescordSW_name = rescordSWStationData[i].name.ToString(); ;
                 obj.transform.GetChild(1).GetComponent<Text>().text = rescordSW_name;
                 obj.transform.GetChild(2).GetComponent<Text>().text = rescordSWStationData[i].time.ToString();
                 obj.transform.GetChild(3).GetComponent<Text>().text = rescordSWStationData[i].value.ToString();
-                string rescordSW_stcd= rescordSWStationData[i].stcd;
+                string rescordSW_stcd = rescordSWStationData[i].stcd;
                 obj.transform.GetComponent<Button>().onClick.AddListener(() =>
                 {
-                    _waterTrendPanel.Show(rescordSW_stcd,rescordSW_name);
+                    _waterTrendPanel.Show(rescordSW_stcd, rescordSW_name);
                 });
                 if (rescordSWStationData[i].dir == 0)
                 {
@@ -248,13 +255,15 @@ public class YZTLayer : YZTRootLayer
                 {
                     obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, 90);
                 }
-                else {
+                else
+                {
                     obj.transform.GetChild(4).localEulerAngles = new Vector3(0, 0, -90);
                 }
                 thing3s.Add(obj);
             }
         }
-        else {
+        else
+        {
             for (int i = 0; i < GlobalData.swDatas.Count; i++)
             {
                 rescordSWStationData[i].name = GlobalData.swDatas[i].STNM;
@@ -269,7 +278,8 @@ public class YZTLayer : YZTRootLayer
                 {
                     rescordSWStationData[i].dir = 0;
                 }
-                else {
+                else
+                {
                     rescordSWStationData[i].dir = -1;
                 }
             }
@@ -297,8 +307,10 @@ public class YZTLayer : YZTRootLayer
         }
     }
 
-    async void InitRainInfo() {
-        await new WaitUntil(() => {
+    async void InitRainInfo()
+    {
+        await new WaitUntil(() =>
+        {
             return GlobalData.qXZDatas.Count > 0;
         });
         int qxzCount = GlobalData.qXZDatas.Count;
@@ -310,10 +322,12 @@ public class YZTLayer : YZTRootLayer
         int value50100 = 0;
         int value100200 = 0;
         int value200 = 0;
-        for (int i = 0; i < qxzCount; i++) {
+        for (int i = 0; i < qxzCount; i++)
+        {
             float value = GlobalData.qXZDatas[i].dropSum6;
-            if (value > maxValue) {
-                
+            if (value > maxValue)
+            {
+
                 maxValue = value;
                 maxName = GlobalData.qXZDatas[i].STNM;
             }
@@ -352,10 +366,12 @@ public class YZTLayer : YZTRootLayer
         rainTextNum[5].text = value200.ToString();
     }
 
-    void InitLayerInfo() {
+    void InitLayerInfo()
+    {
 
         //layerInfoBtns = layerInfo.GetComponentsInChildren<Button>();
-        for (int i = 0; i < layerInfoBtns.Length; i++) {
+        for (int i = 0; i < layerInfoBtns.Length; i++)
+        {
             int temp = i;
             layerInfoBtns[i].onClick.AddListener(() =>
             {
@@ -363,7 +379,8 @@ public class YZTLayer : YZTRootLayer
             });
         }
 
-        layerButton.onClick.AddListener(() => {
+        layerButton.onClick.AddListener(() =>
+        {
             layerInfo.gameObject.SetActive(true);
         });
         layerInfoExitBtn.onClick.AddListener(() =>
@@ -377,7 +394,8 @@ public class YZTLayer : YZTRootLayer
             bool active = baseLayerInfoBtns[0].GetComponent<CanvasGroup>().alpha > 0.5f;
             baseLayerInfoBtns[0].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
             bool newActive = !active;
-            for (int i = 0; i < regionLayerObj.Length; i++) {
+            for (int i = 0; i < regionLayerObj.Length; i++)
+            {
                 regionLayerObj[i].gameObject.SetActive(newActive);
                 regionLayerInfo[i].gameObject.SetActive(newActive);
             }
@@ -409,15 +427,17 @@ public class YZTLayer : YZTRootLayer
         baseLayerInfoBtns[2].GetComponent<CanvasGroup>().alpha = 0.5f;
     }
 
-    void RunTimeLayerClick(int temp) {
+    void RunTimeLayerClick(int temp)
+    {
         bool active = layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha > 0.5f;
         layerInfoBtns[temp].GetComponent<CanvasGroup>().alpha = active ? 0.5f : 1.0f;
         bool newActive = !active;
         ChangeRuntimeLayer(temp, newActive);
     }
 
-    void LeftBtnClick(int index,bool record = true) {
-        if(record)
+    void LeftBtnClick(int index, bool record = true)
+    {
+        if (record)
             currentActiveLeft = index;
         for (int i = 0; i < leftButtons.Length; i++)
         {
@@ -425,13 +445,15 @@ public class YZTLayer : YZTRootLayer
         }
         leftButtons[index].GetComponent<Image>().sprite = sprites[0];
 
-        for (int i = 0; i < leftContent.childCount; i++) {
+        for (int i = 0; i < leftContent.childCount; i++)
+        {
             leftContent.transform.GetChild(i).gameObject.SetActive(false);
         }
-        
+
         leftContent.transform.GetChild(index).gameObject.SetActive(true);
 
-        if (index == 1) {
+        if (index == 1)
+        {
             InitSWHeightInfo();
         }
     }
@@ -456,7 +478,8 @@ public class YZTLayer : YZTRootLayer
                         SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
                         secLayerBtn.SetLayerBtnData(tempDatas[j].name);
                         secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
-                        secLayerBtn.btn.onClick.AddListener(() => {
+                        secLayerBtn.btn.onClick.AddListener(() =>
+                        {
                             CameraManager.SwitchCamera(0);
                             viewMode = ViewMode.normal;
                             StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
@@ -470,11 +493,12 @@ public class YZTLayer : YZTRootLayer
                         });
                         num++;
                     }
-                    
+
                 }
                 layerBtn.secContent.gameObject.SetActive(true);
             }
-            else {
+            else
+            {
                 List<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
                 for (int j = 0; j < tempDatas.Count; j++)
                 {
@@ -484,7 +508,8 @@ public class YZTLayer : YZTRootLayer
                         SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab);
                         secLayerBtn.SetLayerBtnData(tempDatas[j].name);
                         secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
-                        secLayerBtn.btn.onClick.AddListener(() => {
+                        secLayerBtn.btn.onClick.AddListener(() =>
+                        {
                             CameraManager.SwitchCamera(0);
                             viewMode = ViewMode.normal;
                             StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri);
@@ -522,15 +547,17 @@ public class YZTLayer : YZTRootLayer
         layerBtns[0].SetUseful(true);
     }
 
-    void ChangeRightContent(int index) {
-        for (int i = 0; i < infoRight.childCount; i++) {
+    void ChangeRightContent(int index)
+    {
+        for (int i = 0; i < infoRight.childCount; i++)
+        {
             infoRight.GetChild(i).gameObject.SetActive(false);
         }
         infoRight.GetChild(index).gameObject.SetActive(true);
         GameObject title = infoRight.GetChild(index).GetChild(0).GetChild(1).gameObject;
         GameObject text1 = infoRight.GetChild(index).GetChild(0).GetChild(2).gameObject;
-        
-        if (title != null) 
+
+        if (title != null)
         {
             title.GetComponent<Text>().text = GlobalData.layerUnitDatas[index].name;
         }
@@ -605,12 +632,15 @@ public class YZTLayer : YZTRootLayer
         RunTimeLayerClick(5);
 
 
-        
+
     }
 
-    int FindIndexByLayerUnitName(string name) {
-        for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++) {
-            if (GlobalData.layerUnitDatas[i].name == name.Trim()) {
+    int FindIndexByLayerUnitName(string name)
+    {
+        for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
+        {
+            if (GlobalData.layerUnitDatas[i].name == name.Trim())
+            {
                 return i;
             }
         }
@@ -641,8 +671,10 @@ public class YZTLayer : YZTRootLayer
         }
     }
 
-    async Task InitData() {
-        await new WaitUntil(() => {
+    async Task InitData()
+    {
+        await new WaitUntil(() =>
+        {
             return GlobalData.layerUnitDatas.Count > 0;
         });
     }
@@ -655,7 +687,8 @@ public class YZTLayer : YZTRootLayer
         });
     }
 
-    void Init() {
+    void Init()
+    {
         yZT.gameObject.SetActive(false);
         clearBtn.gameObject.SetActive(true);
         pointParent.gameObject.SetActive(true);
@@ -664,7 +697,8 @@ public class YZTLayer : YZTRootLayer
         LeftBtnClick(currentActiveLeft);
     }
 
-    void InitReturnBtn() {
+    void InitReturnBtn()
+    {
         returnBtn.onClick.AddListener(() =>
         {
             CameraManager.SwitchCamera(1);
@@ -673,7 +707,8 @@ public class YZTLayer : YZTRootLayer
         });
     }
 
-    void ChangeRuntimeLayer(int layer,bool show) {
+    void ChangeRuntimeLayer(int layer, bool show)
+    {
         if (show)
         {
             if (cancelLayer.Contains(layer))
@@ -681,22 +716,28 @@ public class YZTLayer : YZTRootLayer
                 cancelLayer.Remove(layer);
             }
         }
-        else {
+        else
+        {
             if (!cancelLayer.Contains(layer))
             {
                 cancelLayer.Add(layer);
             }
         }
-        for (int i = 0; i < runtimePointLib.Count; i++) {
-            if (runtimePointLib[i].layerIDs.Contains(layer)) {
+        for (int i = 0; i < runtimePointLib.Count; i++)
+        {
+            if (runtimePointLib[i].layerIDs.Contains(layer))
+            {
                 if (runtimePointLib[i].layerIDs.Count < 2)
                 {
                     runtimePointLib[i].gameObject.SetActive(show);
                 }
-                else {
+                else
+                {
                     List<int> tempLayers = new List<int>(runtimePointLib[i].layerIDs);
-                    for (int j = 0; j < cancelLayer.Count; j++) {
-                        if (tempLayers.Contains(cancelLayer[j])) {
+                    for (int j = 0; j < cancelLayer.Count; j++)
+                    {
+                        if (tempLayers.Contains(cancelLayer[j]))
+                        {
                             tempLayers.Remove(cancelLayer[j]);
                         }
                     }
@@ -704,7 +745,8 @@ public class YZTLayer : YZTRootLayer
                     {
                         runtimePointLib[i].gameObject.SetActive(false);
                     }
-                    else {
+                    else
+                    {
                         runtimePointLib[i].gameObject.SetActive(true);
                     }
                 }
@@ -717,17 +759,17 @@ public class YZTLayer : YZTRootLayer
         Ray ray = CameraManager.instance.mainCamera.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
 
-        if (Physics.Raycast(ray, out hit,20000,1<<8|1<<9))
+        if (Physics.Raycast(ray, out hit, 20000, 1 << 8 | 1 << 9))
         {
             CameraBird bird = CameraManager.instance.mainCamera.GetComponent<CameraBird>();
             if (hit.collider.gameObject.layer == LayerMask.NameToLayer("EarthTile"))
             {
-                if(bird.transform.position.y > 1000)
+                if (bird.transform.position.y > 1000)
                 {
                     bird.SetCameraToCenterFade(hit.point, 1100);
                 }
             }
-            else if(hit.collider.gameObject.layer == LayerMask.NameToLayer("StaticImportant"))
+            else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("StaticImportant"))
             {
                 StaticImportant si = hit.collider.gameObject.GetComponent<StaticImportant>();
                 int index = StaticLod.instance.OnFoucusStatic(si);
@@ -737,7 +779,7 @@ public class YZTLayer : YZTRootLayer
                 clearBtn.gameObject.SetActive(false);
                 middleContent.gameObject.SetActive(false);
                 rightContent.gameObject.SetActive(false);
-                LeftBtnClick(1,false);
+                LeftBtnClick(1, false);
             }
         }
         else
@@ -745,7 +787,21 @@ public class YZTLayer : YZTRootLayer
             Debug.Log("No hit");
         }
     }
-
+    private void OnEnable()
+    {
+        if (regionLayerObj.Length > 0)
+        {
+            regionLayerObj[0].transform.parent.gameObject.SetActive(true);
+        }
+    }
+    private void OnDisable()
+    {
+        if (regionLayerObj.Length > 0)
+        {
+            regionLayerObj[0].transform.parent.gameObject.SetActive(false);
+        }
+    }
+   
     private void Update()
     {
         if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击
@@ -754,8 +810,10 @@ public class YZTLayer : YZTRootLayer
             startClickPosition = Input.mousePosition;
         }
         clickInterval += Time.deltaTime;
-        if (Input.GetMouseButtonUp(0)) {
-            if (clickInterval < 0.2f && Vector3.Distance(startClickPosition,Input.mousePosition) < 10f) {
+        if (Input.GetMouseButtonUp(0))
+        {
+            if (clickInterval < 0.2f && Vector3.Distance(startClickPosition, Input.mousePosition) < 10f)
+            {
                 if (!CameraManager.instance.secondCamera.enabled)
                 {
                     ShootRay();
@@ -766,9 +824,10 @@ public class YZTLayer : YZTRootLayer
 
     private void LateUpdate()
     {
-        for (int i = 0; i < regionLayerInfo.Length; i++) 
+        for (int i = 0; i < regionLayerInfo.Length; i++)
         {
-            if (regionLayerInfo[i].gameObject.activeSelf) {
+            if (regionLayerInfo[i].gameObject.activeSelf)
+            {
                 regionLayerInfo[i].anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(regionLayerObj[i].transform.position) / Screen.width * 1920.0f;
             }
         }

Some files were not shown because too many files changed in this diff