Esempio n. 1
0
        public ISigmaMap <TileObject> Spawn(ISigmaMap <List <TileObject> > map, ISigmaMap <MazeCell> maze)
        {
            var locationsToSpawn = new HashSet <Location>(locations(maze));

            return(SparseSigmaMap.From(map.Size,
                                       loc => locationsToSpawn.Contains(loc) ? factory(map, maze, loc) : null));
        }
Esempio n. 2
0
        public ISigmaMap <TileObject> Spawn(ISigmaMap <MazeCell> maze)
        {
            var potentialLocations = getSpawnLocations(maze).ToArray();

            var spawnPoints = new HashSet <Location>();

            while (potentialLocations.Length != 0)
            {
                var i = random.Next(potentialLocations.Length);

                var spawnPoint = potentialLocations[i];
                spawnPoints.Add(spawnPoint);

                potentialLocations = potentialLocations
                                     .Where(s => s.EuclideanDistance(spawnPoint) >= config.SpawnDistance)
                                     .ToArray();
            }

            return(SparseSigmaMap.From(maze.Size,
                                       s => IsSpawnPoint(spawnPoints, s, maze.Size) ? factory(s) : null));
        }