123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- 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<LayerBtn> layerBtns = new List<LayerBtn>();
- // Start is called before the first frame update
- public GameObject obsItemPrefab;
- private List<ObsItem> obsItemList = new List<ObsItem>();
- 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>();
- obsPlayerPanel.gameObject.SetActive(false);
- obsItemContent = this.transform.Find("BigSc/ShiPinJuZhen/ScrollView/Viewport/Content");
-
- _obsSearchInputField = this.transform.Find("BigSc/ShiPinJuZhen/InputField").GetComponent<InputField>();
- _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<LayerBtn>();
- 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<LayerUnitData> tempDatas = new List<LayerUnitData>(GlobalData.layerUnitDatas);
- for (int j = 0; j < tempDatas.Count; j++)
- {
- if (tempDatas[j].special == "1")
- {
- int tempJ = j;
- SecLayerBtn secLayerBtn = Instantiate(zTLayer.secLayerBtnPrefab);
- secLayerBtn.SetLayerBtnData(tempDatas[j].name);
- secLayerBtn.GetComponent<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
- secLayerBtn.btn.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
- miniMap.gameObject.SetActive(false);
- ChangeRightContent(tempJ);
- });
- num++;
- }
- }
- layerBtn.secContent.gameObject.SetActive(true);
- }
- else
- {
- List<LayerUnitData> tempDatas = new List<LayerUnitData>(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<RectTransform>().SetParent(layerBtn.secContent.GetComponent<RectTransform>());
- secLayerBtn.btn.onClick.AddListener(() =>
- {
- StaticLod.instance.OnFoucusStatic(tempDatas[tempJ].namePri);
- miniMap.gameObject.SetActive(false);
- ChangeRightContent(tempJ);
- });
- num++;
- }
- }
- }
- layerBtn.btn.GetComponent<Button>().onClick.AddListener(() =>
- {
- for (int j = 0; j < layerBtns.Count; j++)
- {
- layerBtns[j].SetUseful(false);
- layerBtns[j].secContent.gameObject.SetActive(false);
- }
- layerBtns[index].SetUseful(true);
- layerBtns[index].secContent.gameObject.SetActive(true);
- });
- layerBtn.SetLayerBtnData(zTLayer.layerSprite[zTLayer.layerDatas[i].layerID], zTLayer.layerDatas[i].layerName, num.ToString());
- layerBtn.GetComponent<RectTransform>().SetParent(content.GetComponent<RectTransform>());
- layerBtn.transform.localScale = Vector3.one;
- layerBtns.Add(layerBtn);
- }
- content.GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
- layerBtns[0].SetUseful(true);
- }
- void ChangeRightContent(int index)
- {
- rightContent.parent.gameObject.SetActive(true);
- for (int i = 0; i < rightContent.childCount; i++)
- {
- rightContent.GetChild(i).gameObject.SetActive(false);
- }
- rightContent.GetChild(index).gameObject.SetActive(true);
- }
- // Update is called once per frame
- void Update()
- {
- znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
- }
- public void InitObsItems()
- {
- for (int i = 0; i < obsItemList.Count; i++)
- {
- Destroy(obsItemList[i].gameObject);
- }
- obsItemList.Clear();
- var obsDatas = GlobalData.obsDatas;
- for (int i = 0; i < obsDatas.Count; i++)
- {
- var tempObj = Instantiate(obsItemPrefab, obsItemContent).GetComponent<ObsItem>();
- tempObj.SetData(obsDatas[i]);
- tempObj._button.onClick.AddListener(()=>
- {
- ShowObsPanel(tempObj._data);
- });
- obsItemList.Add(tempObj);
- }
- }
-
- public void SearchObsItem(string s_name)
- {
- if (s_name.Equals(""))
- {
- for (int i = 0; i < obsItemList.Count; i++)
- {
- obsItemList[i].gameObject.SetActive(true);
- }
- }
- else
- {
- for (int i = 0; i < obsItemList.Count; i++)
- {
- obsItemList[i].gameObject.SetActive(obsItemList[i]._data.name.Contains(s_name));
- }
- }
- }
-
- public void ShowObsPanel(ObsData _data)
- {
- obsPlayerPanel.gameObject.SetActive(true);
- obsPlayerPanel.SetObsData(_data);
- }
- }
|