using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Serialization; using UnityEngine.UI; using System.Threading.Tasks; using UnityAsync; using WaitUntil = UnityAsync.WaitUntil; public class BigScreenLayer : MonoBehaviour { public VerticalLayoutGroup content; public RectTransform znz; public Button gkButton; public Button normalButton; public Button clearBtn; public Button exitBtn; public Button exitJJBtn; public Button ddysButton; public Button exit_ddysButton; public GameObject gk; public GameObject normal; public YZTLayer zTLayer; public RectTransform miniMap; public RectTransform rightContent; List layerBtns = new List(); // Start is called before the first frame update public GameObject obsItemPrefab; private List obsItemList = new List(); private Transform obsItemContent; public ObsPlayerPanel obsPlayerPanel; private InputField _obsSearchInputField; public GameObject WaterRangeCtrlPanel; async void Start() { CameraManager.SwitchCamera(0); StaticLod.instance.OnFoucusStatic(0); InitButton(); obsPlayerPanel = this.transform.Find("ObsPlayerPanel").GetComponent(); obsPlayerPanel.gameObject.SetActive(false); obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content"); _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent(); _obsSearchInputField.onValueChanged.AddListener(SearchObsItem); await InitData(); InitLayerBtns(); await InitObsData(); InitObsItems(); } void InitButton() { normalButton.onClick.AddListener(()=> { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); }); gkButton.onClick.AddListener(() => { gk.gameObject.SetActive(true); miniMap.gameObject.SetActive(true); rightContent.parent.gameObject.SetActive(false); normal.gameObject.SetActive(false); }); clearBtn.onClick.AddListener(() => { normal.gameObject.SetActive(false); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(true); normalButton.gameObject.SetActive(false); gkButton.gameObject.SetActive(false); clearBtn.gameObject.SetActive(false); ddysButton.gameObject.SetActive(false); }); exitBtn.onClick.AddListener(() => { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(false); normalButton.gameObject.SetActive(true); gkButton.gameObject.SetActive(true); clearBtn.gameObject.SetActive(true); ddysButton.gameObject.SetActive(true); }); exitJJBtn.onClick.AddListener(() => { normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); }); ddysButton.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(-1); normal.gameObject.SetActive(false); gk.gameObject.SetActive(false); normalButton.gameObject.SetActive(false); gkButton.gameObject.SetActive(false); clearBtn.gameObject.SetActive(false); WaterRangeCtrlPanel.SetActive(true); }); exit_ddysButton.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(0); WaterRangeCtrlPanel.SetActive(false); normal.gameObject.SetActive(true); gk.gameObject.SetActive(false); exitBtn.gameObject.SetActive(false); normalButton.gameObject.SetActive(true); gkButton.gameObject.SetActive(true); clearBtn.gameObject.SetActive(true); ddysButton.gameObject.SetActive(true); }); // public Button ddysButton; // public Button exit_ddysButton; } async Task InitData() { await new WaitUntil(() => { return GlobalData.layerUnitDatas.Count > 0; }); } async Task InitObsData() { await new WaitUntil(() => { return GlobalData.obsDatas.Count > 0; }); } void InitLayerBtns() { layerBtns = new List(); for (int i = 0; i < zTLayer.layerDatas.Length; i++) { LayerBtn layerBtn = Instantiate(zTLayer.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(zTLayer.secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri); miniMap.gameObject.SetActive(false); ChangeRightContent(tempJ); }); num++; } } layerBtn.secContent.gameObject.SetActive(true); } else { List tempDatas = new List(GlobalData.layerUnitDatas); for (int j = 0; j < tempDatas.Count; j++) { Debug.Log(zTLayer.layerDatas.Length); Debug.Log(i); if ((int)tempDatas[j].type == zTLayer.layerDatas[i].layerID) { int tempJ = j; SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab); secLayerBtn.SetLayerBtnData(tempDatas[j].name); secLayerBtn.GetComponent().SetParent(layerBtn.secContent.GetComponent()); secLayerBtn.btn.onClick.AddListener(() => { StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].name_pri); miniMap.gameObject.SetActive(false); ChangeRightContent(tempJ); }); num++; } } } layerBtn.btn.GetComponent