using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Level3Manager : MonoSingleton { public Camera[] cameraGroup; public Button[] viewChangeBtnGroup; public RenderTexture renderTexture; public DriveManager driveManager; public CameraManager cameraManager; public GameObject huapo; public GameObject cameraView; public Button ReturnMainViewBtn; public Button AnalyBtn; public GameObject AnalyPanel; public bool isAnaly = false; public bool showKuang = false; public Text EducoderText; public Transform kuangParent; public float KuangDistanceValue = 1; public GameObject overTip; [Header("镜头移动面板")] public GameObject CameraMovePanel; public ButtonExtension upBtn; public ButtonExtension downBtn; public ButtonExtension leftBtn; public ButtonExtension rightBtn; protected override void Awake() { base.Awake(); driveManager.Init(); cameraManager.Init(); InitChangeView(); InitMovePanel(); AnalyBtn.onClick.AddListener(() => { isAnaly = true; AnalyBtn.gameObject.SetActive(false); AnalyPanel.gameObject.SetActive(true); }); } public void StartTimeAction(float time, Action action) { StartCoroutine(TimeAction(time, action)); } IEnumerator TimeAction(float time, Action action) { yield return new WaitForSeconds(time); action.Invoke(); } private void Start() { RandomStone(); } private void Update() { if (isAnaly&&(EducoderText.text.Contains("Y")|| EducoderText.text.Contains("True"))) { //RandomStone(); AnalyPanel.SetActive(false); showKuang = true; kuangParent.gameObject.SetActive(true); for (int j = 0; j < cameraGroup.Length; j++) { cameraGroup[j].depth = 0; cameraGroup[j].gameObject.SetActive(false); } cameraGroup[0].depth = 2; cameraGroup[0].gameObject.SetActive(true); overTip.SetActive(true); ReturnMainViewBtn.image.enabled = false; ReturnMainViewBtn.image.raycastTarget = false; ReturnMainViewBtn.GetComponentInChildren().enabled = false; isAnaly = false; } } [ContextMenu("滑坡触发")] private void RandomStone() { huapo.SetActive(true); RandomStone[] stones = GameObject.FindObjectsOfType(); for (int i = 0; i < stones.Length; i++) { stones[i].Init(); } } private void InitChangeView() { //路灯视角切换 for (int i = 0; i < viewChangeBtnGroup.Length; i++) { int index = i; viewChangeBtnGroup[i].onClick.AddListener(() => { for (int j = 0; j < cameraGroup.Length; j++) { cameraGroup[j].depth = 0; cameraGroup[j].gameObject.SetActive(false); } if (index == 0&& showKuang) { kuangParent.gameObject.SetActive(true); } else { kuangParent.gameObject.SetActive(false); } cameraGroup[index].depth = 2; cameraGroup[index].gameObject.SetActive(true); cameraView.SetActive(true); ReturnMainViewBtn.gameObject.SetActive(true); CameraMovePanel.SetActive(false); AnalyBtn.gameObject.SetActive(true); }); } //返回主视角 ReturnMainViewBtn.onClick.AddListener(() => { Camera.main.depth = 2; for (int i = 0; i < cameraGroup.Length; i++) { cameraGroup[i].depth = 0; } ReturnMainViewBtn.gameObject.SetActive(false); cameraView.SetActive(false); CameraMovePanel.SetActive(true); AnalyBtn.gameObject.SetActive(false); }); } private void InitMovePanel() { upBtn.onPress.AddListener(() => { CameraManager.Instance.MoveMainCamera(-Vector3.back); }); downBtn.onPress.AddListener(() => { CameraManager.Instance.MoveMainCamera(Vector3.back); }); leftBtn.onPress.AddListener(() => { CameraManager.Instance.MoveMainCamera(Vector3.left); }); rightBtn.onPress.AddListener(() => { CameraManager.Instance.MoveMainCamera(-Vector3.left); }); } public void SendPassResult() { EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true); } }