| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityAsync;
- using WaitUntil = UnityAsync.WaitUntil;
- public class ThreeDNav : MonoBehaviour
- {
- public Vector2[] targetPos;
- public Image s_image;
- public List<Button> btns;
- public List<RectTransform> layers;
- public GameObject content;
- public RectTransform znz;
- public GCJKLayer gCJK;
- public ObsPlayerPanel obsPlayerPanel;
- public static ThreeDNav instance;
- private void Awake()
- {
- instance = this;
- }
- private void Start()
- {
- CameraManager.SwitchCamera(0);
- InitButton();
- StaticLod.instance.OnFoucusStatic("TaoKou");
- InitPoint();
- }
- void InitButton()
- {
- btns = new List<Button>();
- Button[] bts = this.GetComponentsInChildren<Button>();
- for (int i = 0; i < bts.Length; i++)
- {
- btns.Add(bts[i]);
- }
- layers = new List<RectTransform>();
- for (int i = 0; i < content.transform.childCount; i++)
- {
- layers.Add(content.transform.GetChild(i).GetComponent<RectTransform>());
- }
- for (int i = 0; i < btns.Count; i++)
- {
- int index = i;
- btns[index].onClick.AddListener(() =>
- {
- for (int j = 0; j < layers.Count; j++)
- {
- layers[j].gameObject.SetActive(false);
- }
- for (int j = 0; j < btns.Count; j++)
- {
- btns[j].GetComponentInChildren<Text>().color = new Color32(137, 147, 173, 255);
- }
- obsPlayerPanel.gameObject.SetActive(false);
- btns[index].GetComponentInChildren<Text>().color = Color.white;
- Tweener tw = s_image.GetComponent<RectTransform>().DOLocalMoveX(targetPos[index].x, 0.3f);
- tw.SetEase(Ease.OutBack);
- if (index < layers.Count)
- {
- layers[index].gameObject.SetActive(true);
- }
- if (index == 4)
- {
- StaticLod.instance.OnFoucusStatic("Bird0");
- }
- else if (index == 1)
- {
- gCJK.OnTaoKouClick();
- }
- else
- {
- StaticLod.instance.OnFoucusStatic("TaoKou");
- }
- });
- }
- }
- public Item0 item0Prefab;
- public GameObject item0Parent;
- public Sprite[] hotPointSprite;
- void OnNewPointClick(HotPointData temp, Item0 item0)
- {
- CameraManager.SwitchCamera(0);
- StaticLod.instance.OnFoucusStatic(item0.staticImp);
- }
- int FindIndexByLayerUnitName(string name)
- {
- for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
- {
- if (GlobalData.layerUnitDatas[i].name == name.Trim())
- {
- return i;
- }
- }
- return -1;
- }
- async void InitPoint()
- {
- await new WaitUntil(() =>
- {
- return GlobalData.hotPointDatas.Count > 0;
- });
- GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
- List<Item0> item0s = new List<Item0>();
- for (int i = 0; i < GlobalData.hotPointDatas.Count; i++)
- {
- //if()
- HotPointData temp = GlobalData.hotPointDatas[i];
- int tempI = i;
- if ((int)temp.type == 6 || (int)temp.type == 7 || (int)temp.type == 9)
- {
- int index = FindIndexByLayerUnitName(temp.name);
- Item0 item0 = Instantiate(item0Prefab, Vector3.zero, Quaternion.identity);
- item0.InitPoint(hotPointSprite[(int)(temp.type)], temp.namePri, temp.name, GlobalData.layerUnitDatas[index].special);
- item0s.Add(item0);
- item0.onPointClick = () =>
- {
- OnNewPointClick(temp, item0);
- };
- }
- }
- for (int i = 0; i < item0s.Count; i++)
- {
- if (item0s[i].mSpecial != "1")
- item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
- }
- for (int i = 0; i < item0s.Count; i++)
- {
- if (item0s[i].mSpecial == "1")
- item0s[i].GetComponent<RectTransform>().SetParent(item0Parent.transform);
- }
- }
- public void ShowObsPanel(ObsData _data)
- {
- obsPlayerPanel.gameObject.SetActive(true);
- obsPlayerPanel.SetObsData(_data);
- obsPlayerPanel.SetTitle(_data.name);
- }
- private void Update()
- {
- znz.transform.rotation = Quaternion.Lerp(znz.transform.rotation, Quaternion.Euler(0, 0, CameraManager.instance.mainCamera.transform.localEulerAngles.y), Time.deltaTime * 4);
- }
- }
|