Пример #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());
        }
Пример #3
0
        private List <DrivingNode> AddDirectionTurns(List <DrivingNode> drivingNodeList, Point startPoint)
        {
            if (drivingNodeList.Count > 0)
            {
                Point point     = new Point(drivingNodeList[drivingNodeList.Count - 1].GetLocationX() - startPoint.X, drivingNodeList[drivingNodeList.Count - 1].GetLocationY() - startPoint.Y);
                int   direction = AngleStuff.GetDirection(point);

                DrivingNode node = drivingNodeList[drivingNodeList.Count - 1];
                node.SetDrivingDirection((byte)direction);
                drivingNodeList[drivingNodeList.Count - 1] = node;

                for (int i = drivingNodeList.Count - 2; i > -1; i--)
                {
                    point     = new Point(drivingNodeList[i].GetLocationX() - drivingNodeList[i + 1].GetLocationX(), drivingNodeList[i].GetLocationY() - drivingNodeList[i + 1].GetLocationY());
                    direction = AngleStuff.GetDirection(point);

                    DrivingNode node1 = drivingNodeList[i];
                    node1.SetDrivingDirection((byte)direction);
                    drivingNodeList[i] = node1;
                }
            }
            return(drivingNodeList);
        }