Exemplo n.º 1
0
 public RandomSpawner(Random random,
                      SpawnerConfig config,
                      Func <Location, TileObject> factory,
                      Func <ISigmaMap <MazeCell>, IEnumerable <Location> > spawnLocations)
 {
     this.random       = random;
     this.factory      = factory;
     this.config       = config;
     getSpawnLocations = spawnLocations;
 }
Exemplo n.º 2
0
        public DistanceSpawner(
            Random random,
            SpawnerConfig config,
            Func<Location, TileObject> factory)

            : base(random, config, factory,
                  maze => Location.Square(maze.Size)
                    .Where(s => maze[s] == MazeCell.Empty)
                    .Select(s => new { Value = s, Distance = config.EmitterLocation.ManhattanDistance(s) })
                    .Where(s => s.Distance >= config.StartRadius)
                    .Where(s => s.Distance < config.EndRadius)
                    .Select(s => s.Value)
                    .Where(s => s.IsAboveDiagonal(maze.Size)))
        { }
Exemplo n.º 3
0
        public GraphSpawner(
            Random random,
            SpawnerConfig config,
            Func <Location, TileObject> factory)

            : base(random, config, factory,
                   maze => Graph.BreadthFirstTraverse(Location.Zero, s => s.Neighborhood
                                                      .InsideAndAboveDiagonal(maze.Size)
                                                      .Where(n => maze[n] == MazeCell.Empty))
                   .Select((x, i) => new { Distance = i, Node = x.Node })
                   .SkipWhile(x => x.Distance < config.StartRadius)
                   .TakeWhile(x => x.Distance < config.EndRadius)
                   .Select(x => x.Node))
        {
        }
Exemplo n.º 4
0
        public TopologicSpawner(
            Random random,
            SpawnerConfig config,
            Func <Vector2i, TileObject> factory)

            : base(random, config, factory,
                   maze => Graph.BreadthFirstTraverse(SigmaIndex.Zero, s => s.Neighborhood
                                                      .Clamp(maze.Size)
                                                      .Where(n => maze[n] == MazeCell.Empty))
                   .Select((x, i) => new { Distance = i, Node = x.Node })
                   .SkipWhile(x => x.Distance < config.StartRadius)
                   .TakeWhile(x => x.Distance < config.EndRadius)
                   .Select(x => x.Node))
        {
        }
Exemplo n.º 5
0
        public DistanceSpawner(
            Random random,
            SpawnerConfig config,
            Func <ISigmaMap <List <TileObject> >, ISigmaMap <MazeCell>, Location, TileObject> factory,
            Func <ISigmaMap <List <TileObject> >, ISigmaMap <MazeCell>, Location, bool> predicate = null,
            Func <TileObject, Location, TileObject> symmetricFactory = null)

            : base(random, config, factory, symmetricFactory,
                   (map, maze) => Location.Square(maze.Size)
                   .Where(s => predicate?.Invoke(map, maze, s) ??
                          maze[s] == MazeCell.Empty && (map[s] == null || map[s].Count == 0))
                   .Select(s => new { Value = s, Distance = config.EmitterLocation.ManhattanDistance(s) })
                   .Where(s => s.Distance >= config.StartRadius)
                   .Where(s => s.Distance < config.EndRadius)
                   .Select(s => s.Value)
                   .Where(s => s.IsAboveDiagonal(maze.Size)))
        {
        }
Exemplo n.º 6
0
        public GraphSpawner(
            Random random,
            SpawnerConfig config,
            Func <ISigmaMap <List <TileObject> >, ISigmaMap <MazeCell>, Location, TileObject> factory,
            Func <ISigmaMap <List <TileObject> >, ISigmaMap <MazeCell>, Location, bool> predicate = null,
            Func <TileObject, Location, TileObject> symmetricFactory = null)

            : base(random, config, factory, symmetricFactory,
                   (map, maze) => Graph.BreadthFirstTraverse(Location.Zero, s => s.Neighborhood
                                                             .InsideAndAboveDiagonal(maze.Size)
                                                             .Where(n => maze[n] == MazeCell.Empty))
                   .Select((x, i) => new { Distance = i, Node = x.Node })
                   .SkipWhile(x => x.Distance < config.StartRadius)
                   .TakeWhile(x => x.Distance < config.EndRadius)
                   .Select(x => x.Node)
                   .Where(s => predicate?.Invoke(map, maze, s) ?? (map[s] == null || map[s].Count == 0)))
        {
        }