Beispiel #1
0
        private int GetDirection(DrivingNode one, DrivingNode two)
        {
            int x = one.GetLocationX() - two.GetLocationX();
            int y = one.GetLocationY() - two.GetLocationY();

            return(AngleStuff.GetDirection(new Point(x, y)));
        }
Beispiel #2
0
        public void AdvanceNode(DrivingNode nextNode)
        {
            if (WorldController.world.tileGrid[backTileX, backTileY].vehicle == vehicleParameters.vehicle)
            {
                WorldController.world.tileGrid[backTileX, backTileY].vehicle = null;
            }

            backTileX = tileX;
            backTileY = tileY;
            tileX     = nextNode.GetLocationX();
            tileY     = nextNode.GetLocationY();
            WorldController.world.tileGrid[tileX, tileY].vehicle = vehicleParameters.vehicle;

            vehicleParameters.indicatorDirection = nextNode.indicatorDirection;
        }
Beispiel #3
0
        private void CalculateCorners()
        {
            if (drivingNodeList.Count > 2)
            {
                int currentDirection = GetDirection(drivingNodeList[drivingNodeList.Count - 2], drivingNodeList[drivingNodeList.Count - 1]);

                for (int i = drivingNodeList.Count - 1; i > 1; i--)
                {
                    int newDirection = GetDirection(drivingNodeList[i - 1], drivingNodeList[i]);

                    if (newDirection != currentDirection)
                    {
                        Direction turnDirection = AngleStuff.GetTurnDirection(currentDirection, newDirection);


                        if (currentDirection % 2 == 0 && newDirection % 2 == 0)
                        {
                            DrivingNode drivingNode = drivingNodeList[i];
                            drivingNode.SetUseByPassTurn(currentDirection, newDirection);
                            drivingNodeList[i] = drivingNode;
                        }

                        currentDirection = newDirection;

                        for (int p = i - 2; p < i + 6; p++)
                        {
                            if (p > 0 && p < drivingNodeList.Count)
                            {
                                if (drivingNodeList[p].isRoad() && drivingNodeList[p].indicatorDirection == Direction.NONE || drivingNodeList[p].isRoad() && p < i)
                                {
                                    drivingNodeList[p].SetIndicatorDirection(turnDirection);
                                }
                            }
                        }
                    }
                }
            }
        }