protected void PlaceMonsters(IEnumerable <ICell> spawZone, int minMonsterNb, int maxMonsterNb) { // On place entre 1 et 4 monstres var numberOfMonsters = Dice.Roll(minMonsterNb.ToString() + "D" + maxMonsterNb.ToString()); for (int i = 0; i < numberOfMonsters; i++) { string monsterName = _existingMonsters[Dice.Roll("1D" + Game.Level.ToString()) - 1]; // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(spawZone); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster if (randomRoomLocation != Point.Zero) { Monster monster; switch (monsterName) { case "Coupeur": monster = Coupeur.Create(Game.Level); break; case "Bodybuilder": monster = Bodybuilder.Create(Game.Level); break; default: monster = Coquard.Create(Game.Level); break; } monster.Coord = randomRoomLocation; _map.AddMonster(monster); } } }
private void PlaceMonsters() { foreach (Connection connection in _map.Connections) { List <ICell> spawnZone = _map.GetCellsInCircle(connection.TerminalA.X, connection.TerminalA.Y, 6).Where(c => c.IsWalkable).ToList(); for (int i = 0; i < Dice.Roll("2D3-2"); i++) { ICell spawnCell = spawnZone[Game.Random.Next(spawnZone.Count - 1)]; var cutter = Coupeur.Create(Game.Level); cutter.X = spawnCell.X; cutter.Y = spawnCell.Y; _map.AddMonster(cutter); } spawnZone = _map.GetCellsInCircle(connection.TerminalB.X, connection.TerminalB.Y, 6).Where(c => c.IsWalkable).ToList(); for (int i = 0; i < Dice.Roll("2D3"); i++) { ICell spawnCell = spawnZone[Game.Random.Next(spawnZone.Count - 1)]; var cutter = Coupeur.Create(Game.Level); cutter.X = spawnCell.X; cutter.Y = spawnCell.Y; _map.AddMonster(cutter); } } }