You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LawCheck : MonoBehaviour
{
[HideInInspector]
public float maxSpeed ;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Car")
{
maxSpeed = DriveManager.Instance.OverSpeedMaxValue;
Car car = null;
car = other.GetComponent<Car>();
if (car == null) return;
if (car.overSpeed >= maxSpeed-5)
{
DriveManager.Instance.SetCarSoundTip(car);
Debug.Log(car.CarIDCard);
LawCheckList.Instance.AddCarID(car.CarIDCard,"-超速");
}
Debug.Log("违章检测·");
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player" || other.gameObject.tag == "Car")
{
maxSpeed = DriveManager.Instance.OverSpeedMaxValue;
Car car = null;
car = other.GetComponent<Car>();
if (car == null) return;
if (car.overSpeed >= maxSpeed)
{
DriveManager.Instance.SetCarSoundTip(car);
Debug.Log(car.CarIDCard);
LawCheckList.Instance.AddCarID(car.CarIDCard,"-超速");
}
}
}
}