You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
4.5 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Level4lManager : MonoSingleton<Level4lManager>
{
public Camera[] cameraGroup;
public Button[] viewChangeBtnGroup;
public RenderTexture renderTexture;
public DriveManager driveManager;
public CameraManager cameraManager;
public GameObject tafang;
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()
{
}
private void Update()
{
if (isAnaly && (EducoderText.text.Contains("Y")|| EducoderText.text.Contains("True")) || EducoderText.text.Contains("t"))
{
//RandomStone();
tafang.SetActive(true);
AnalyPanel.SetActive(false);
showKuang = true;
kuangParent.gameObject.SetActive(true);
isAnaly = false;
for (int j = 0; j < cameraGroup.Length; j++)
{
cameraGroup[j].depth = 0;
cameraGroup[j].gameObject.SetActive(false);
}
cameraGroup[1].depth = 2;
cameraGroup[1].gameObject.SetActive(true);
overTip.SetActive(true);
ReturnMainViewBtn.image.enabled = false;
ReturnMainViewBtn.image.raycastTarget = false;
ReturnMainViewBtn.GetComponentInChildren<Text>().enabled = false;
}
}
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);
}
}