103 lines
2.5 KiB
C#
103 lines
2.5 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ControlStopCar : MonoBehaviour
|
|
{
|
|
public static ControlStopCar instance;
|
|
public Toggle Open;
|
|
public Toggle Close;
|
|
/// <summary>
|
|
/// 停车杆
|
|
/// </summary>
|
|
public Transform Parkingpoles;
|
|
/// <summary>
|
|
/// 是否放下停车杆
|
|
/// </summary>
|
|
bool IsPutitdownpoles;
|
|
/// <summary>
|
|
/// 停车场视角
|
|
/// </summary>
|
|
public Transform StopCarPos;
|
|
/// <summary>
|
|
/// 红绿灯视角
|
|
/// </summary>
|
|
public Transform LightPos;
|
|
/// <summary>
|
|
/// 语音按钮
|
|
/// </summary>
|
|
public Button Audiosbt;
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
void Start()
|
|
{
|
|
Open.onValueChanged.AddListener((a) =>
|
|
{
|
|
if (Open.isOn)
|
|
{
|
|
Open.interactable = false;
|
|
Controlpoles(false);
|
|
Audiosbt.interactable = false;
|
|
}
|
|
|
|
});
|
|
//Close.onValueChanged.AddListener((a) =>
|
|
//{
|
|
// Open.interactable = false;
|
|
// Controlpoles(true);
|
|
//});
|
|
}
|
|
|
|
public void SetPostLight(Transform pos)
|
|
{
|
|
pos.SetLocalPositionAndRotation(LightPos.position, LightPos.localRotation);
|
|
}
|
|
public void SetPostStopCar(Transform pos)
|
|
{
|
|
pos.SetLocalPositionAndRotation(StopCarPos.position, StopCarPos.localRotation);
|
|
}
|
|
/// <summary>
|
|
/// 控制杆是否放下
|
|
/// </summary>
|
|
/// <param name="isputdown">true:放下杆 false:抬起杆</param>
|
|
public void Controlpoles(bool isputdown)
|
|
{
|
|
if (isputdown)
|
|
{
|
|
Parkingpoles.GetComponent<BoxCollider>().enabled = true;
|
|
Parkingpoles.DOLocalRotateQuaternion(Quaternion.Euler(0, -90, 0), 1);
|
|
}
|
|
else
|
|
{
|
|
Parkingpoles.GetComponent<BoxCollider>().enabled = false;
|
|
Parkingpoles.DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 0), 1);
|
|
}
|
|
}
|
|
|
|
public void AudiosTalk(string talk)
|
|
{
|
|
//if (talk == "关闭闸门")
|
|
//{
|
|
// Open.interactable = true;
|
|
// Close.interactable = true;
|
|
// Close.isOn = true;
|
|
// Controlpoles(false);
|
|
//}
|
|
if (talk == "开启闸门")
|
|
{
|
|
Open.interactable = true;
|
|
Open.isOn = true;
|
|
Controlpoles(false);
|
|
}
|
|
else if (talk != "开启闸门")
|
|
{
|
|
Open.interactable = true;
|
|
Close.interactable = true;
|
|
}
|
|
}
|
|
}
|