Exemplo n.º 1
0
    private Position getRandomWallPositionInRange(Maze maze, Position minCorner, Position maxCorner)
    {
        int area = Position.Area(minCorner, maxCorner);
        int loopCount = 0;

        Position randomPosition = null;

        while (loopCount++ < area &&
               (randomPosition == null ||
         maze.MazePieceFromPosition(randomPosition) != MazePiece.Wall)) {
            randomPosition = Position.RandomPositionInRange(minCorner, maxCorner);
        }

        return maze.MazePieceFromPosition(randomPosition) == MazePiece.Wall?randomPosition:null;
    }