tijiao
This commit is contained in:
parent
2db928f303
commit
959a760171
|
@ -409,6 +409,7 @@
|
|||
<Compile Include="Assets\Script\Old\Trigger_road.cs" />
|
||||
<Compile Include="Assets\Script\Old\Early_Warning.cs" />
|
||||
<Compile Include="Assets\Script\Manaegr\CarTempManager.cs" />
|
||||
<Compile Include="Assets\Script\AccidentManager.cs" />
|
||||
<None Include="Assets\Plugin\Standard Assets\Effects\ImageEffects\Shaders\Tonemapper.shader" />
|
||||
<None Include="Assets\Plugin\Hard Surface Pro\HardSurface Shaders\HardSurfaceProScreenSpaceReflection.cginc" />
|
||||
<None Include="Assets\Plugin\Hard Surface Pro\HardSurface Shaders\HardSurface Free Opaque Specular.shader" />
|
||||
|
|
|
@ -91,11 +91,11 @@ ModelImporter:
|
|||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 2
|
||||
animationType: 1
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,152 @@
|
|||
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;
|
||||
|
||||
public Animation zuiwei;
|
||||
public Animator diandongcheren;
|
||||
void Close()
|
||||
{
|
||||
for (int i = 0; i < uis.transform.Find("UI").childCount; i++)
|
||||
{
|
||||
uis.transform.Find("UI").GetChild(i).gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
zuiwei.gameObject.SetActive(false);
|
||||
diandongcheren.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
public void Tr(Transform other, bool b = false)
|
||||
{
|
||||
triggerName = other.name;
|
||||
|
||||
|
||||
if (other.transform.tag == "People")
|
||||
{
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
uis.transform.Find("UI").Find("撞倒行人").gameObject.SetActive(true);
|
||||
}
|
||||
else if (other.name == "Box_Collider")
|
||||
{
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
uis.transform.Find("UI").Find("汽车追尾").gameObject.SetActive(true);
|
||||
}
|
||||
else if (other.name == "爆胎")
|
||||
{
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
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.SetActive(true);
|
||||
uis.transform.Find("UI").Find("礼让行人").gameObject.SetActive(true);
|
||||
carGearControl.mingdi = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
carGearControl.mingdi = true;
|
||||
}
|
||||
}else if (other.name == "隧道汽车追尾")
|
||||
{
|
||||
StartCoroutine(PlayAnimation());
|
||||
}else if (other.name == "电动车穿行")
|
||||
{
|
||||
StartCoroutine(diandongche());
|
||||
}else if (other.name == "刹车失灵")
|
||||
{
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
uis.transform.Find("UI").Find("刹车失灵").gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
IEnumerator PlayAnimation()
|
||||
{
|
||||
zuiwei.gameObject.SetActive(true);
|
||||
|
||||
zuiwei.Play("donghua");
|
||||
// 等待动画播放完毕
|
||||
yield return new WaitForSeconds(zuiwei["donghua"].length);
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
uis.transform.Find("UI").Find("汽车追尾").gameObject.SetActive(true);
|
||||
// 在这里编写动画播放完之后的代码
|
||||
// 例如: Debug.Log("动画播放完成");
|
||||
}
|
||||
IEnumerator diandongche()
|
||||
{
|
||||
diandongcheren.gameObject.SetActive(true);
|
||||
|
||||
diandongcheren.Play("diandongchedonghua");
|
||||
// 等待动画播放完毕
|
||||
yield return new WaitForSeconds(diandongcheren.GetCurrentAnimatorStateInfo(0).length);
|
||||
Close();
|
||||
uis.SetActive(true);
|
||||
uis.transform.Find("UI").Find("电动车穿行").gameObject.SetActive(true);
|
||||
// 在这里编写动画播放完之后的代码
|
||||
// 例如: Debug.Log("动画播放完成");
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 51829e07d23b2224e9c6207ad43f28e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,5 +1,6 @@
|
|||
using EVP;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
|
@ -47,14 +48,21 @@ namespace Script
|
|||
public GameObject uiGame;
|
||||
|
||||
public GameObject carMenuUI;
|
||||
|
||||
public GameObject accident; //事故UI
|
||||
private bool ClutchPedalPositionBool;
|
||||
|
||||
|
||||
public bool mingdi = false;
|
||||
public AccidentManager accidentManager;
|
||||
|
||||
public Transform ttt;
|
||||
void Start()
|
||||
{
|
||||
vehicleController = GetComponent<VehicleController>();
|
||||
vehicleStandardInput = GetComponent<VehicleStandardInput>();
|
||||
|
||||
StartModbus();
|
||||
// StartModbus();
|
||||
ModBusQueue();
|
||||
}
|
||||
|
||||
|
@ -86,17 +94,17 @@ namespace Script
|
|||
while (true)
|
||||
{
|
||||
// Debug.Log(client.modbusQueue.Count);
|
||||
if (client.modbusQueue.Count > 0)
|
||||
{
|
||||
// Debug.Log(client.modbusQueue.Count);
|
||||
// if (client.modbusQueue.Count > 0)
|
||||
// {
|
||||
// // Debug.Log(client.modbusQueue.Count);
|
||||
//
|
||||
// carData = client.modbusQueue.Dequeue();
|
||||
|
||||
carData = client.modbusQueue.Dequeue();
|
||||
|
||||
// if (ModbusTcpClient.modbusTcpClient.modbusQueue.Count > 0)
|
||||
// {
|
||||
// // Debug.Log(ModbusTcpClient.modbusTcpClient.modbusQueue.Count);
|
||||
//
|
||||
// carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
|
||||
if (ModbusTcpClient.modbusTcpClient.modbusQueue.Count > 0)
|
||||
{
|
||||
// Debug.Log(ModbusTcpClient.modbusTcpClient.modbusQueue.Count);
|
||||
|
||||
carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
|
||||
|
||||
|
||||
//方向盘
|
||||
|
@ -114,7 +122,7 @@ namespace Script
|
|||
case 1: //1前进档
|
||||
if (carData.HandbrakeStatus == 0)
|
||||
{
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
if (carData.AcceleratorPedalPosition > 20)
|
||||
{
|
||||
vehicleController.throttleInput = 1;
|
||||
}
|
||||
|
@ -132,7 +140,7 @@ namespace Script
|
|||
case 2: //2倒挡
|
||||
if (carData.HandbrakeStatus == 0)
|
||||
{
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
if (carData.AcceleratorPedalPosition > 20)
|
||||
{
|
||||
vehicleController.throttleInput = -0.5f;
|
||||
}
|
||||
|
@ -193,6 +201,16 @@ namespace Script
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (mingdi)
|
||||
{
|
||||
if (carData.HornStatus == 1)
|
||||
{
|
||||
mingdi = false;
|
||||
accidentManager.Tr(ttt,true);
|
||||
}
|
||||
}
|
||||
|
||||
//转向灯和双闪
|
||||
if (carData.ButtonData == 1)
|
||||
{
|
||||
|
@ -265,39 +283,48 @@ namespace Script
|
|||
break;
|
||||
}
|
||||
|
||||
//踩离合弹出菜单UI
|
||||
if (carData.ClutchPedalPosition > 30)
|
||||
|
||||
if (accident.activeInHierarchy)
|
||||
{
|
||||
if (!ClutchPedalPositionBool)
|
||||
if (carData.AcceleratorPedalPosition > 90)
|
||||
{
|
||||
ClutchPedalPositionBool = true;
|
||||
carMenuUI.SetActive(true);
|
||||
accident.transform.Find("重置").GetComponent<UnityEngine.UI.Button>().onClick.Invoke();
|
||||
}
|
||||
}
|
||||
else if (carData.ClutchPedalPosition <= 0)
|
||||
else
|
||||
{
|
||||
ClutchPedalPositionBool = false;
|
||||
//踩离合弹出菜单UI
|
||||
if (carData.ClutchPedalPosition > 30)
|
||||
{
|
||||
if (!ClutchPedalPositionBool)
|
||||
{
|
||||
ClutchPedalPositionBool = true;
|
||||
carMenuUI.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (carData.ClutchPedalPosition <= 0)
|
||||
{
|
||||
ClutchPedalPositionBool = false;
|
||||
}
|
||||
|
||||
if (carMenuUI.activeInHierarchy)
|
||||
{
|
||||
if (carData.ButtonData == 4)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Back();
|
||||
}
|
||||
else if (carData.ButtonData == 2)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Next();
|
||||
}
|
||||
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (carMenuUI.activeInHierarchy)
|
||||
{
|
||||
if (carData.ButtonData == 4)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Back();
|
||||
}
|
||||
else if (carData.ButtonData == 2)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Next();
|
||||
}
|
||||
|
||||
if (carData.AcceleratorPedalPosition > 30)
|
||||
{
|
||||
carMenuUI.GetComponent<CarMenuManager>().Click();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//刹车
|
||||
if (carData.BrakePedalPosition > 30)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ public class InitialTrafficLightSequence : MonoBehaviour
|
|||
{
|
||||
foreach (var v in trafficLightText)
|
||||
{
|
||||
v.text = $"{state}\n{Mathf.CeilToInt(time)}秒";
|
||||
v.text = $"{Mathf.CeilToInt(time)}";
|
||||
v.color = state == "红灯" ? Color.red : Color.green;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,7 +35,7 @@ public class TrafficLightManager : MonoBehaviour
|
|||
|
||||
public void UpdateTrafficLightTexture(TrafficLightState state)
|
||||
{
|
||||
Debug.Log("123");
|
||||
// Debug.Log("123");
|
||||
|
||||
foreach (var light in trafficLights)
|
||||
{
|
||||
|
@ -113,12 +113,12 @@ public class TrafficLightManager : MonoBehaviour
|
|||
|
||||
void FixedUpdate()
|
||||
{
|
||||
Debug.Log("Delta Time: " + Time.deltaTime);
|
||||
// Debug.Log("Delta Time: " + Time.deltaTime);
|
||||
foreach (var group in lightGroups)
|
||||
{
|
||||
Debug.Log("Before: " + group.timer);
|
||||
// Debug.Log("Before: " + group.timer);
|
||||
// group.timer -= Time.deltaTime;
|
||||
Debug.Log("After: " + group.timer);
|
||||
// Debug.Log("After: " + group.timer);
|
||||
|
||||
// 更新红绿灯状态
|
||||
UpdateTrafficLightGroup(group);
|
||||
|
|
|
@ -9,6 +9,18 @@ namespace Script
|
|||
{
|
||||
public class test : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
Debug.Log("进入");
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
Debug.Log("tuichu");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Texture2D ttt;
|
||||
public void HHHH()
|
||||
|
|
Loading…
Reference in New Issue