예제 #1
0
        public RoadPiece[] getRoad(Level level)
        {
            Vector2 start = level.getStart();
            Vector2 end   = level.getFinish();

            if (level.getPos(start) != null || level.getPos(end) != null)
            {
                return(null);
            }
            List <Vector2> previous = new List <Vector2>();

            while (true)
            {
                previous.Add(start);
                if (start.x == end.x && start.y == end.y)
                {
                    return(makeRoadPieces(ref previous));
                }
                Vector2[] neighbors = getNeighbors(level, start, ref previous);
                if (neighbors.Length != 1)
                {
                    return(null);
                }
                start = neighbors[0];
            }
        }
예제 #2
0
 private void displayRoadPoints()
 {
     placeRoad(VectorCalculation.revertToOrigin(level.getFinish(), level));
     placeRoad(VectorCalculation.revertToOrigin(level.getStart(), level));
 }