private void spawnSimple(int enemiesSpawned, LevelGenOutput output, int[] guaranteedEnemiesPlaced, EnemySelector enemySelector, int difficulty, List <LevelGenMap.Coordinate> openTiles, bool spawnPlayers) { // Guaranteed enemies for (int i = 0; i < output.Input.GuaranteedEnemiesByDifficulty.Length; ++i) { while (guaranteedEnemiesPlaced[i] < output.Input.GuaranteedEnemiesByDifficulty[i]) { int enemyId = enemySelector.ChooseEnemyOfDifficulty(i); guaranteedEnemiesPlaced[i] = guaranteedEnemiesPlaced[i] + 1; ++enemiesSpawned; _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId)); } } // Remaining enemies for (; enemiesSpawned < this.NumEnemies; ++enemiesSpawned) { int enemyId = enemySelector.ChooseEnemy(difficulty); _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId)); } // Players if (spawnPlayers) { bool first = true; List <LevelGenMap.Coordinate> tiles = openTiles; for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i) { if (DynamicData.GetSessionPlayer(i).HasJoined) { LevelGenMap.Coordinate playerSpawn = findGoodOpenPosition(tiles, 0); _playerSpawns.Add(playerSpawn.integerVector); if (first) { first = false; List <LevelGenMap.Coordinate> nearbySpawns = new List <LevelGenMap.Coordinate>(); foreach (LevelGenMap.Coordinate coord in openTiles) { if (Mathf.Abs(coord.x - playerSpawn.x) + Mathf.Abs(coord.y - playerSpawn.y) <= this.MaxPlayerSpawnDistance) { nearbySpawns.Add(coord); } } if (nearbySpawns.Count >= DynamicData.MAX_PLAYERS) { tiles = nearbySpawns; } } else { openTiles.Remove(playerSpawn); } } } } }
private int pickMaybeGuaranteedEnemy(int guaranteesSpawned, int totalGuarantees, int enemiesSpawned, int difficulty, int[] guaranteedEnemiesPlaced, LevelGenOutput output, EnemySelector enemySelector) { if (guaranteesSpawned < totalGuarantees && Random.Range(0, this.NumEnemies) < enemiesSpawned + (totalGuarantees - guaranteesSpawned)) { // Use guarantee for united-spawn int guaranteedDifficulty = 0; for (int i = 0; i < guaranteedEnemiesPlaced.Length; ++i) { if (guaranteedEnemiesPlaced[i] < output.Input.GuaranteedEnemiesByDifficulty[i]) { guaranteedDifficulty = i; if (Random.value > 0.5f) { break; } } } return(enemySelector.ChooseEnemyOfDifficulty(guaranteedDifficulty)); } return(enemySelector.ChooseEnemy(difficulty)); }
private int pickMaybeGuaranteedEnemy(int guaranteesSpawned, int totalGuarantees, int enemiesSpawned, int difficulty, int[] guaranteedEnemiesPlaced, LevelGenOutput output, EnemySelector enemySelector) { if (guaranteesSpawned < totalGuarantees && Random.Range(0, this.NumEnemies) < enemiesSpawned + (totalGuarantees - guaranteesSpawned)) { // Use guarantee for united-spawn int guaranteedDifficulty = 0; for (int i = 0; i < guaranteedEnemiesPlaced.Length; ++i) { if (guaranteedEnemiesPlaced[i] < output.Input.GuaranteedEnemiesByDifficulty[i]) { guaranteedDifficulty = i; if (Random.value > 0.5f) break; } } return enemySelector.ChooseEnemyOfDifficulty(guaranteedDifficulty); } return enemySelector.ChooseEnemy(difficulty); }
private void spawnSimple(int enemiesSpawned, LevelGenOutput output, int[] guaranteedEnemiesPlaced, EnemySelector enemySelector, int difficulty, List<LevelGenMap.Coordinate> openTiles, bool spawnPlayers) { // Guaranteed enemies for (int i = 0; i < output.Input.GuaranteedEnemiesByDifficulty.Length; ++i) { while (guaranteedEnemiesPlaced[i] < output.Input.GuaranteedEnemiesByDifficulty[i]) { int enemyId = enemySelector.ChooseEnemyOfDifficulty(i); guaranteedEnemiesPlaced[i] = guaranteedEnemiesPlaced[i] + 1; ++enemiesSpawned; _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId)); } } // Remaining enemies for (; enemiesSpawned < this.NumEnemies; ++enemiesSpawned) { int enemyId = enemySelector.ChooseEnemy(difficulty); _enemySpawns.Add(new EnemySpawnGroup(findGoodOpenPosition(openTiles, output.Input.MinDistanceBetweenSpawns).integerVector, enemyId)); } // Players if (spawnPlayers) { bool first = true; List<LevelGenMap.Coordinate> tiles = openTiles; for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i) { if (DynamicData.GetSessionPlayer(i).HasJoined) { LevelGenMap.Coordinate playerSpawn = findGoodOpenPosition(tiles, 0); _playerSpawns.Add(playerSpawn.integerVector); if (first) { first = false; List<LevelGenMap.Coordinate> nearbySpawns = new List<LevelGenMap.Coordinate>(); foreach (LevelGenMap.Coordinate coord in openTiles) { if (Mathf.Abs(coord.x - playerSpawn.x) + Mathf.Abs(coord.y - playerSpawn.y) <= this.MaxPlayerSpawnDistance) nearbySpawns.Add(coord); } if (nearbySpawns.Count >= DynamicData.MAX_PLAYERS) tiles = nearbySpawns; } else { openTiles.Remove(playerSpawn); } } } } }