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.
187 lines
4.8 KiB
187 lines
4.8 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Level3Manager : MonoSingleton<Level3Manager>
|
|
{
|
|
|
|
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<Text>().enabled = false;
|
|
|
|
isAnaly = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
[ContextMenu("滑坡触发")]
|
|
private void RandomStone()
|
|
{
|
|
|
|
huapo.SetActive(true);
|
|
|
|
RandomStone[] stones = GameObject.FindObjectsOfType<RandomStone>();
|
|
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);
|
|
}
|
|
|
|
}
|