private void OnTriggerEnter(Collider other)
    {
        if (!Handler.IsSomethingOnFire)
        {
            return;
        }
        if (other.gameObject.GetComponent <CarFrontCollider>() == null)
        {
            return;
        }
        VehicleBehaviour vehicle = other.gameObject.GetComponentInParent <VehicleBehaviour>();

        if (vehicle == null)
        {
            return;
        }
        if (ReferenceEquals(vehicle, _parent))
        {
            return;
        }
        if (!vehicle.CompareTag("firebrigade"))
        {
            return;
        }
        if (_parent.EmergencyBrake)
        {
            _parent.EmergencyBrake       = false;
            _parent._brakeTorqueConstant = 0f;
        }
        _parent.MaxSpeed = vehicle._speedConstant;
    }
示例#2
0
 // make sure that vehicle has been removed from list
 public void CheckRemoveZ(VehicleBehaviour vehicle)
 {
     if (!_vehiclesOnZ.Contains(vehicle))
     {
         return;
     }
     print(vehicle.gameObject.name + " not removed from Z list in " + gameObject.name);
     if (vehicle.CompareTag("firebrigade"))
     {
         vehicle.Continue();
     }
     _vehiclesOnX.Remove(vehicle);
 }
    private void OnTriggerExit(Collider other)
    {
        if (!Handler.IsSomethingOnFire)
        {
            return;
        }
        if (other.gameObject.GetComponent <CarBackCollider>() == null)
        {
            return;
        }
        VehicleBehaviour vehicle = other.gameObject.GetComponentInParent <VehicleBehaviour>();

        if (vehicle == null)
        {
            return;
        }
        if (vehicle.CompareTag("firebrigade"))
        {
            _parent._speedConstant = RegularSpeed;
        }
    }
    // move vehicles if able
    private void MoveVehicles()
    {
        for (int i = _vehiclesTurning.Count - 1; i >= 0; i--)
        {
            VehicleBehaviour vehicle = _vehiclesTurning[i];
            if (Handler.IsSomethingOnFire && vehicle.CompareTag("firebrigade"))
            {
                vehicle.SetNextRoad();
                vehicle.Continue();
                _vehiclesTurning.Remove(vehicle);
                continue;
            }
            if (vehicle.NextRoad == null)
            {
                vehicle.SetNextRoad();
            }

            if (vehicle.NextRoad != null)
            {
                if (vehicle.NextRoad.GetComponent <WaypointPath>().GetCongestion() >
                    vehicle.NextRoad.GetComponent <WaypointPath>().CongestionThreshold)
                {
                    vehicle.SetNextRoad();
                }
            }

            if (vehicle.IsUnableToMove)
            {
                vehicle.Stop();
            }
            else if (vehicle.LeftJunctionLeave || vehicle.IsGoingStraightAtJunction)
            {
                _vehiclesTurning.Remove(vehicle);
            }
            else if (vehicle.RightJunctionCrossing)
            {
                if (_rightLane.TrafficInLane)
                {
                    vehicle.Stop();
                }
                else
                {
                    vehicle.Continue();
                    _vehiclesTurning.Remove(vehicle);
                }
            }
            else if (vehicle.RightJunctionJoin)
            {
                if (_rightLane.TrafficInLane || _leftLane.TrafficInLane)
                {
                    vehicle.Stop();
                }
                else
                {
                    vehicle.Continue();
                    _vehiclesTurning.Remove(vehicle);
                }
            }
            else if (vehicle.LeftJunctionJoin)
            {
                if (_rightLane.TrafficInLane)
                {
                    vehicle.Stop();
                }
                else
                {
                    vehicle.Continue();
                    _vehiclesTurning.Remove(vehicle);
                }
            }
        }
    }