Exemple #1
0
        void TriggerStop(GameObject _vehicle)
        {
            VehicleAI vehicleAI = _vehicle.GetComponent <VehicleAI>();

            //Depending on the waypoint threshold, the car can be either on the target segment or on the past segment
            int vehicleSegment = vehicleAI.GetSegmentVehicleIsIn();

            if (!IsPrioritySegment(vehicleSegment))
            {
                if (vehiclesQueue.Count > 0 || vehiclesInIntersection.Count > 0)
                {
                    vehicleAI.vehicleStatus = Status.STOP;
                    vehiclesQueue.Add(_vehicle);
                }
                else
                {
                    vehiclesInIntersection.Add(_vehicle);
                    vehicleAI.vehicleStatus = Status.SLOW_DOWN;
                }
            }
            else
            {
                vehicleAI.vehicleStatus = Status.SLOW_DOWN;
                vehiclesInIntersection.Add(_vehicle);
            }
        }
Exemple #2
0
        void TriggerLight(GameObject _vehicle)
        {
            VehicleAI vehicleAI      = _vehicle.GetComponent <VehicleAI>();
            int       vehicleSegment = vehicleAI.GetSegmentVehicleIsIn();

            if (IsRedLightSegment(vehicleSegment))
            {
                vehicleAI.vehicleStatus = Status.STOP;
                vehiclesQueue.Add(_vehicle);
            }
            else
            {
                vehicleAI.vehicleStatus = Status.GO;
            }
        }