tijiao
This commit is contained in:
parent
fe48e9e022
commit
750ba5f1db
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script;
|
||||
using UnityEngine;
|
||||
|
||||
public class AccidentManager : MonoBehaviour
|
||||
|
@ -8,32 +9,55 @@ public class AccidentManager : MonoBehaviour
|
|||
public GameObject uis;
|
||||
private string triggerName;
|
||||
|
||||
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
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)
|
||||
{
|
||||
triggerName = other.name;
|
||||
uis.SetActive(true);
|
||||
for (int i = 0; i < uis.transform.childCount; i++)
|
||||
{
|
||||
uis.transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
if (other.transform.tag == "People")
|
||||
{
|
||||
uis.transform.Find("撞倒行人").gameObject.SetActive(true);
|
||||
Close();
|
||||
uis.transform.Find("UI").Find("撞倒行人").gameObject.SetActive(true);
|
||||
}
|
||||
else if (other.name == "chechufa")
|
||||
else if (other.name == "Box_Collider")
|
||||
{
|
||||
uis.transform.Find("汽车追尾").gameObject.SetActive(true);
|
||||
Close();
|
||||
uis.transform.Find("UI").Find("汽车追尾").gameObject.SetActive(true);
|
||||
}
|
||||
else if (other.name == "爆胎")
|
||||
{
|
||||
uis.transform.Find("爆胎").gameObject.SetActive(true);
|
||||
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 == "礼让行人")
|
||||
{
|
||||
Close();
|
||||
uis.transform.Find("UI").Find("礼让行人").gameObject.SetActive(true);
|
||||
carGearControl.mingdi = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Tr(other.transform);
|
||||
|
||||
// switch (other.name)
|
||||
// {
|
||||
|
@ -60,11 +84,18 @@ public class AccidentManager : MonoBehaviour
|
|||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
for (int i = 0; i < uis.transform.childCount; i++)
|
||||
{
|
||||
uis.transform.GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
uis.SetActive(false);
|
||||
// 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);
|
||||
}
|
||||
}
|
|
@ -52,6 +52,11 @@ namespace Script
|
|||
public GameObject accident; //事故UI
|
||||
private bool ClutchPedalPositionBool;
|
||||
|
||||
|
||||
public bool mingdi = false;
|
||||
public AccidentManager accidentManager;
|
||||
|
||||
public Transform ttt;
|
||||
void Start()
|
||||
{
|
||||
vehicleController = GetComponent<VehicleController>();
|
||||
|
@ -117,7 +122,7 @@ namespace Script
|
|||
case 1: //1前进档
|
||||
if (carData.HandbrakeStatus == 0)
|
||||
{
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
if (carData.AcceleratorPedalPosition > 20)
|
||||
{
|
||||
vehicleController.throttleInput = 1;
|
||||
}
|
||||
|
@ -135,7 +140,7 @@ namespace Script
|
|||
case 2: //2倒挡
|
||||
if (carData.HandbrakeStatus == 0)
|
||||
{
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
if (carData.AcceleratorPedalPosition > 20)
|
||||
{
|
||||
vehicleController.throttleInput = -0.5f;
|
||||
}
|
||||
|
@ -196,6 +201,16 @@ namespace Script
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (mingdi)
|
||||
{
|
||||
if (carData.HornStatus == 1)
|
||||
{
|
||||
mingdi = false;
|
||||
accidentManager.Tr(ttt);
|
||||
}
|
||||
}
|
||||
|
||||
//转向灯和双闪
|
||||
if (carData.ButtonData == 1)
|
||||
{
|
||||
|
@ -271,7 +286,7 @@ namespace Script
|
|||
|
||||
if (accident.activeInHierarchy)
|
||||
{
|
||||
if (carData.ClutchPedalPosition > 30)
|
||||
if (carData.AcceleratorPedalPosition > 90)
|
||||
{
|
||||
accident.transform.Find("重置").GetComponent<UnityEngine.UI.Button>().onClick.Invoke();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue