Compare commits

..

No commits in common. "1e4febc98f54e9fe09043f156df3fa93db6eb9b2" and "1ea8b11e52a31796d6bbb0a7359dd503e3ad3f9c" have entirely different histories.

10 changed files with 103157 additions and 94475 deletions

View File

@ -409,7 +409,6 @@
<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" />

View File

@ -91,11 +91,11 @@ ModelImporter:
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 1
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1

File diff suppressed because it is too large Load Diff

View File

@ -1,152 +0,0 @@
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);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 51829e07d23b2224e9c6207ad43f28e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,5 @@
using EVP;
using UnityEngine;
using UnityEngine.UIElements;
namespace Script
{
@ -48,21 +47,14 @@ 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();
}
@ -94,17 +86,17 @@ namespace Script
while (true)
{
// Debug.Log(client.modbusQueue.Count);
// if (client.modbusQueue.Count > 0)
// {
// // Debug.Log(client.modbusQueue.Count);
//
// carData = client.modbusQueue.Dequeue();
if (client.modbusQueue.Count > 0)
{
// Debug.Log(client.modbusQueue.Count);
if (ModbusTcpClient.modbusTcpClient.modbusQueue.Count > 0)
{
// Debug.Log(ModbusTcpClient.modbusTcpClient.modbusQueue.Count);
carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
carData = client.modbusQueue.Dequeue();
// if (ModbusTcpClient.modbusTcpClient.modbusQueue.Count > 0)
// {
// // Debug.Log(ModbusTcpClient.modbusTcpClient.modbusQueue.Count);
//
// carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
//方向盘
@ -122,7 +114,7 @@ namespace Script
case 1: //1前进档
if (carData.HandbrakeStatus == 0)
{
if (carData.AcceleratorPedalPosition > 20)
if (carData.AcceleratorPedalPosition > 30)
{
vehicleController.throttleInput = 1;
}
@ -140,7 +132,7 @@ namespace Script
case 2: //2倒挡
if (carData.HandbrakeStatus == 0)
{
if (carData.AcceleratorPedalPosition > 20)
if (carData.AcceleratorPedalPosition > 30)
{
vehicleController.throttleInput = -0.5f;
}
@ -201,16 +193,6 @@ namespace Script
}
if (mingdi)
{
if (carData.HornStatus == 1)
{
mingdi = false;
accidentManager.Tr(ttt,true);
}
}
//转向灯和双闪
if (carData.ButtonData == 1)
{
@ -283,48 +265,39 @@ namespace Script
break;
}
if (accident.activeInHierarchy)
//踩离合弹出菜单UI
if (carData.ClutchPedalPosition > 30)
{
if (carData.AcceleratorPedalPosition > 90)
if (!ClutchPedalPositionBool)
{
accident.transform.Find("重置").GetComponent<UnityEngine.UI.Button>().onClick.Invoke();
ClutchPedalPositionBool = true;
carMenuUI.SetActive(true);
}
}
else
else if (carData.ClutchPedalPosition <= 0)
{
//踩离合弹出菜单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();
}
}
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 (carData.BrakePedalPosition > 30)
{

View File

@ -34,7 +34,7 @@ public class InitialTrafficLightSequence : MonoBehaviour
{
foreach (var v in trafficLightText)
{
v.text = $"{Mathf.CeilToInt(time)}";
v.text = $"{state}\n{Mathf.CeilToInt(time)}";
v.color = state == "红灯" ? Color.red : Color.green;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -9,18 +9,6 @@ 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()