110 lines
3.0 KiB
C#
110 lines
3.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Script;
|
|
using UnityEngine;
|
|
|
|
public class AccidentManager : MonoBehaviour
|
|
{
|
|
public GameObject uis;
|
|
private string triggerName;
|
|
|
|
public GameObject[] baotai;
|
|
public CarGearControl carGearControl;
|
|
void Close()
|
|
{
|
|
for (int i = 0; i < uis.transform.Find("UI").childCount; i++)
|
|
{
|
|
uis.transform.Find("UI").GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
|
|
uis.SetActive(true);
|
|
}
|
|
|
|
|
|
public void Tr(Transform other, bool b = false)
|
|
{
|
|
triggerName = other.name;
|
|
|
|
|
|
if (other.transform.tag == "People")
|
|
{
|
|
Close();
|
|
uis.transform.Find("UI").Find("撞倒行人").gameObject.SetActive(true);
|
|
}
|
|
else if (other.name == "Box_Collider")
|
|
{
|
|
Close();
|
|
uis.transform.Find("UI").Find("汽车追尾").gameObject.SetActive(true);
|
|
}
|
|
else if (other.name == "爆胎")
|
|
{
|
|
Close();
|
|
uis.transform.Find("UI").Find("爆胎").gameObject.SetActive(true);
|
|
|
|
for (int i = 0; i < baotai.Length; i++)
|
|
{
|
|
baotai[i].SetActive(true);
|
|
}
|
|
}else if (other.name == "礼让行人")
|
|
{
|
|
if (b)
|
|
{
|
|
Close();
|
|
uis.transform.Find("UI").Find("礼让行人").gameObject.SetActive(true);
|
|
carGearControl.mingdi = false;
|
|
}
|
|
else
|
|
{
|
|
carGearControl.mingdi = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
Tr(other.transform);
|
|
|
|
// switch (other.name)
|
|
// {
|
|
// case "刹车失灵":
|
|
// uis.transform.Find("刹车失灵").gameObject.SetActive(true);
|
|
// break;
|
|
// case "礼让行人":
|
|
// uis.transform.Find("礼让行人").gameObject.SetActive(true);
|
|
// break;
|
|
// case "汽车追尾":
|
|
// uis.transform.Find("汽车追尾").gameObject.SetActive(true);
|
|
// break;
|
|
// case "电动车穿行":
|
|
// uis.transform.Find("电动车穿行").gameObject.SetActive(true);
|
|
// break;
|
|
// case "撞倒行人":
|
|
// uis.transform.Find("撞倒行人").gameObject.SetActive(true);
|
|
// break;
|
|
// case "爆胎":
|
|
// uis.transform.Find("爆胎").gameObject.SetActive(true);
|
|
// break;
|
|
// }
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
// for (int i = 0; i < uis.transform.childCount; i++)
|
|
// {
|
|
// uis.transform.GetChild(i).gameObject.SetActive(false);
|
|
// }
|
|
//
|
|
// for (int i = 0; i < baotai.Length; i++)
|
|
// {
|
|
// baotai[i].SetActive(false);
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
// uis.SetActive(false);
|
|
}
|
|
} |