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; [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 LayerUnitData { public bool special; public LayerUnitType type; public float longitude; public float latitude; public string name; public string name_pri; public string text1; public string text2; } [System.Serializable] public class HotPointData { public LayerUnitType type; public float longitude; public float latitude; public string name; public string name_pri; } 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 Sprite[] sprites; // Start is called before the first frame update async void Awake() { viewMode = ViewMode.miniMap; await InitData(); Init(); InitLeftBtn(); InitLayerInfo(); InitLayerBtns(); InitReturnBtn(); await InitPointData(); InitPoint(); } void InitLeftBtn() { for (int i = 0; i < leftButtons.Length; i++) { int temp = i; leftButtons[i].onClick.AddListener(() => { LeftBtnClick(temp); }); } LeftBtnClick(0); } void InitLayerInfo() { layerButton.onClick.AddListener(() => { layerInfo.gameObject.SetActive(true); }); layerInfoExitBtn.onClick.AddListener(() => { layerInfo.gameObject.SetActive(false); }); } void LeftBtnClick(int index,bool record = true) { if(record) currentActiveLeft = index; for (int i = 0; i < leftButtons.Length; i++) { leftButtons[i].GetComponent().sprite = sprites[1]; } leftButtons[index].GetComponent().sprite = sprites[0]; for (int i = 0; i < leftContent.childCount; i++) { leftContent.transform.GetChild(i).gameObject.SetActive(false); } leftContent.transform.GetChild(index).gameObject.SetActive(true); } void InitLayerBtns() { layerBtns = new List(); for (int i = 0; i < layerDatas.Length; i++) { LayerBtn layerBtn = Instantiate(layerBtnPrefab); layerBtn.SetUseful(false); int index = i; int num = 0; if (i == 0) { List tempDatas = new List(GlobalData.layerUnitDatas); for (int j = 0; j < tempDatas.Count; j++) { if (tempDatas[j].special) { int tempJ = j; SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { CameraManager.SwitchCamera(0); viewMode = ViewMode.normal; StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri); yZT.gameObject.SetActive(true); ChangeRightContent(tempJ); middleContent.gameObject.SetActive(false); rightContent.gameObject.SetActive(false); LeftBtnClick(1, false); }); num++; } } layerBtn.secContent.gameObject.SetActive(true); } else { List tempDatas = new List(GlobalData.layerUnitDatas); for (int j = 0; j < tempDatas.Count; j++) { if ((int)tempDatas[j].type == layerDatas[i].layerID) { int tempJ = j; SecLayerBtn secLayerBtn = Instantiate(secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { CameraManager.SwitchCamera(0); viewMode = ViewMode.normal; StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri); yZT.gameObject.SetActive(true); ChangeRightContent(tempJ); middleContent.gameObject.SetActive(false); rightContent.gameObject.SetActive(false); LeftBtnClick(1, false); }); num++; } } } layerBtn.btn.GetComponent