示例#1
0
        private bool CalcIncomingCornerOrParkedVehicle(int distance)
        {
            //This could also include stoplights etc
            if (drivingNodeList.Count - distance > 0)
            {
                DrivingNode next = drivingNodeList[drivingNodeList.Count - distance];

                Tile nextTile = GetTile(distance);

                //  bool isComing = next.useTurnOverride || nextTile.IsStopLightBlockDirection(vehicleParameters.directionTravelling, out bool none);

                bool isComing = next.GetDrivingDirection() != vehicleParameters.directionTravelling || nextTile.IsStopLightBlockDirection(vehicleParameters.directionTravelling, out bool none);

                if (isComing)
                {
                    return(true);
                }
                else
                {
                    //We have a slow vehicle in front of us so we should slow down
                    Tile tile = WorldController.world.tileGrid[next.GetLocationX(), next.GetLocationY()];
                    isComing = tile.IsSlowVehicle();
                    return(tile.IsSlowVehicle());
                }
            }

            if (drivingNodeList.Count == 1) //Last node
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public Vector2 GetNextDestination(out bool incomingCornerOrStopLight)
        {
            //Clear any previous destination
            // last one on the list
            DrivingNode next = drivingNodeList[drivingNodeList.Count - 1];


            location.AdvanceNode(next);
            drivingNodeList.RemoveAt(drivingNodeList.Count - 1);
            incomingCornerOrStopLight             = CalcIncomingCornerOrParkedVehicle(1);
            vehicleParameters.directionTravelling = next.GetDrivingDirection();
            //If this is wrong we were meant to get the direction of the last node

            if (!incomingCornerOrStopLight)
            {
                incomingCornerOrStopLight = CalcIncomingCornerOrParkedVehicle(2);
            }


            //find next destination.  //Mark the map
            return(next.GetLocationVector());
        }