using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using UnityAsync; using WaitUntil = UnityAsync.WaitUntil; using DG.Tweening; using Unity.VisualScripting; using System.Reflection; [System.Serializable] public class YZTLayerData { public string layerName; public int layerID; } public enum LayerUnitType { ZZ = 1, BZ, NC, QXZ, JK, QT } [System.Serializable] public class JKYJData { public int normal; public int total; public int fault; public List items; } [System.Serializable] public class JKYJChildData { public string name; public string model; public string ipAddress; public string deviceId; public string channelId; public bool onlineStatus; } public class GCGKData { public string name; public string type; public int count; } [System.Serializable] public class LayerUnitData { public string special; public LayerUnitType type; public float longitude; public float latitude; public string name; public string namePri; public string text1; public string text2; public string GetTypeName() { string result = ""; switch (type) { case LayerUnitType.ZZ: result = "闸站"; break; case LayerUnitType.BZ: result = "泵站"; break; case LayerUnitType.NC: result = "农场"; break; case LayerUnitType.QXZ: result = "气象站"; break; case LayerUnitType.JK: result = "监控"; break; case LayerUnitType.QT: result = "其他"; break; } return result; } } [System.Serializable] public class HotPointData { public LayerUnitType type; public float longitude; public float latitude; public string name; public string namePri; } [System.Serializable] public class SWStationRecordData { public string name; public string time; public float value; public int dir; public string stcd = "0"; } public class YZTLayer : YZTRootLayer { public VerticalLayoutGroup content; public Sprite[] layerSprite; public Sprite[] hotPointSprite; public LayerBtn layerBtnPrefab; public SecLayerBtn secLayerBtnPrefab; public YZTLayerData[] layerDatas; public RectTransform leftContent; public RectTransform middleContent; public RectTransform rightContent; List layerBtns = new List(); public RuntimePoint pointPrefab; public GameObject runtimePointObj; public RectTransform pointParent; List runtimePointLib = new List(); public GameObject yZTMini; public GameObject yZT; public RectTransform infoRight; public Button returnBtn; private float clickInterval; private Vector3 startClickPosition; public Button[] leftButtons; public Button layerButton; public int currentActiveLeft = 0; public RectTransform layerInfo; public Button layerInfoExitBtn; public Button[] baseLayerInfoBtns; public Button[] layerInfoBtns; public List cancelLayer = new List(); public Sprite[] sprites; public Text rainText; public Text[] rainTextNum; public GameObject thingPrefab; public RectTransform thingParent; public List rescordSWStationData = new List(); public List thing3s = new List(); public Button clearBtn; public RectTransform regionParent; public RectTransform[] riverLayerInfo; public RectTransform[] lakeLayerInfo; public GameObject regionObjParent; public GameObject regionObjParent2; public GameObject[] regionLayerObj; public GameObject[] riverLayerObj; public GameObject[] lakeLayerObj; public List region2LayerObj = new List(); // Start is called before the first frame update public WaterTrendPanel _waterTrendPanel; public Item0 item0Prefab; public GameObject item0Parent; public Text normalCount; public Text badCount; public Text stopCount; public Text allCount; public Thing0 thing0Prefab; public RectTransform thing0Content; public Text totalJKNum; public Text normalJKNum; public Text errorJKNum; public Text currentSWText; public Text avgSWText; public Text sfSWText; public Text jjSWText; public Text bzSWText; async void Awake() { viewMode = ViewMode.miniMap; _waterTrendPanel = this.transform.Find("WaterTrendPanel").GetComponent(); _waterTrendPanel.Init(); await InitData(); Init(); InitLeftBtn(); InitLayerInfo(); InitLayerBtns(); InitReturnBtn(); InitGCGKData(); InitJKYJData(); InitSWYJData(); InitRainInfo(); InitSWHeightInfo(); await InitPointData(); InitPoint(); } void InitGCGKData() { normalCount.text = GlobalData.gcgkContents[0].count.ToString() + "个"; badCount.text = GlobalData.gcgkContents[1].count.ToString() + "个"; stopCount.text = GlobalData.gcgkContents[2].count.ToString() + "个"; allCount.text = (GlobalData.gcgkContents[0].count + GlobalData.gcgkContents[1].count + GlobalData.gcgkContents[2].count).ToString() + "个"; } async void InitJKYJData() { await new WaitUntil(() => { return GlobalData.byJKYJContents.total > 0 && GlobalData.tkJKYJContents.total > 0; }); for (int i = 0; i < GlobalData.byJKYJContents.items.Count; i++) { Thing0 thing0 = Instantiate(thing0Prefab); thing0.transform.SetParent(thing0Content); thing0.transform.localPosition = Vector3.zero; thing0.transform.localScale = Vector3.one; thing0.SetData(i.ToString(), GlobalData.byJKYJContents.items[i].name, "补元", "开启", GlobalData.byJKYJContents.items[i].onlineStatus?"正常":"故障"); } for (int i = 0; i < GlobalData.tkJKYJContents.items.Count; i++) { Thing0 thing0 = Instantiate(thing0Prefab); thing0.transform.SetParent(thing0Content); thing0.transform.localPosition = Vector3.zero; thing0.transform.localScale = Vector3.one; thing0.SetData((i + GlobalData.byJKYJContents.total).ToString(), GlobalData.tkJKYJContents.items[i].name, "套口", "开启", GlobalData.tkJKYJContents.items[i].onlineStatus ? "正常" : "故障"); } totalJKNum.text = (GlobalData.byJKYJContents.total + GlobalData.tkJKYJContents.total).ToString(); normalJKNum.text = (GlobalData.byJKYJContents.normal + GlobalData.tkJKYJContents.normal).ToString(); errorJKNum.text = (GlobalData.byJKYJContents.fault + GlobalData.tkJKYJContents.fault).ToString(); } async void InitSWYJData() { await new WaitUntil(() => { return GlobalData.TaoKouShuiWeiDataList.Count > 1; }); float value1 = GlobalData.TaoKouShuiWeiDataList[0].value; float value2 = GlobalData.TaoKouShuiWeiDataList[1].value; if (value1 > 1000) { value1 = value1 / 100.0f; } if (value2 > 1000) { value2 = value2 / 100.0f; } avgSWText.text = $"{((value1 + value2) / 2).ToString("0.00")}"; sfSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].floodProtectionLevel}"; jjSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].warningLevel}"; bzSWText.text = $"{GlobalData.threeLevelShuiWeiDatas[1].guaranteeLevel}"; currentSWText.text = value1.ToString("0.00"); } void InitLeftBtn() { for (int i = 0; i < leftButtons.Length; i++) { int temp = i; leftButtons[i].onClick.AddListener(() => { LeftBtnClick(temp); }); } LeftBtnClick(0); clearBtn.onClick.AddListener(() => { if (clearBtn.GetComponent().sprite == sprites[0]) { for (int i = 0; i < leftButtons.Length; i++) leftButtons[i].gameObject.SetActive(false); clearBtn.GetComponent().sprite = sprites[1]; DOTween.To(() => leftContent.GetComponent().anchoredPosition, x => leftContent.GetComponent().anchoredPosition = x, new Vector2(-219.74f, 0), 0.3f); DOTween.To(() => leftContent.GetComponent().alpha, x => leftContent.GetComponent().alpha = x, 0, 0.3f); pointParent.gameObject.SetActive(true); DOTween.To(() => middleContent.GetComponent().anchoredPosition, x => middleContent.GetComponent().anchoredPosition = x, new Vector2(400f, 540), 0.3f); DOTween.To(() => rightContent.GetComponent().anchoredPosition, x => rightContent.GetComponent().anchoredPosition = x, new Vector2(220.6f, 419.8932f), 0.3f); DOTween.To(() => rightContent.GetComponent().alpha, x => rightContent.GetComponent().alpha = x, 0, 0.3f); clearBtn.GetComponent().DOLocalMoveX(-827f, 0.3f); } else { for (int i = 0; i < leftButtons.Length; i++) leftButtons[i].gameObject.SetActive(true); clearBtn.GetComponent().sprite = sprites[0]; DOTween.To(() => leftContent.GetComponent().anchoredPosition, x => leftContent.GetComponent().anchoredPosition = x, new Vector2(219.74f, 0), 0.3f); DOTween.To(() => leftContent.GetComponent().alpha, x => leftContent.GetComponent().alpha = x, 1, 0.3f); pointParent.gameObject.SetActive(true); DOTween.To(() => middleContent.GetComponent().anchoredPosition, x => middleContent.GetComponent().anchoredPosition = x, new Vector2(0f, 540), 0.3f); DOTween.To(() => rightContent.GetComponent().anchoredPosition, x => rightContent.GetComponent().anchoredPosition = x, new Vector2(-220.6f, 419.8932f), 0.3f); DOTween.To(() => rightContent.GetComponent().alpha, x => rightContent.GetComponent().alpha = x, 1, 0.3f); clearBtn.GetComponent().DOLocalMoveX(-457f, 0.3f); } }); } async void InitSWHeightInfo() { await new WaitUntil(() => { return GlobalData.swDatas.Count > 0; }); if (rescordSWStationData.Count < 1) { 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.time = DateTime.Now.ToString("MM/dd HH:mm"); sWStationRecordData.stcd = GlobalData.swDatas[i].STCD; rescordSWStationData.Add(sWStationRecordData); } for (int i = 0; i < rescordSWStationData.Count; i++) { GameObject obj = Instantiate(thingPrefab); obj.GetComponent().SetParent(thingParent); obj.transform.localScale = Vector3.one; obj.transform.GetChild(0).GetComponent().text = (i + 1).ToString(); string rescordSW_name = rescordSWStationData[i].name.ToString(); ; obj.transform.GetChild(1).GetComponent().text = rescordSW_name; obj.transform.GetChild(2).GetComponent().text = rescordSWStationData[i].time.ToString(); obj.transform.GetChild(3).GetComponent().text = rescordSWStationData[i].value.ToString(); string rescordSW_stcd = rescordSWStationData[i].stcd; obj.transform.GetComponent