/// <summary> /// Make a chance to place 1 to 4 monsters in every room except the starting room with the player. /// </summary> private void PlaceMonsters() { if (GameData.Data.CurrentLevel == GameData.Data.Levels - 1) { GenerateBeholder(); } foreach (var segment in map.segments) { if (segment.x == playerXsegment && segment.y == playerYsegment) { continue; } if (Dice.Roll("1D10") <= 8) // Each seggment has a 70% chance of having monsters { var numberOfMonsters = Dice.Roll("1D4"); // Generate between 1 and 4 monsters for (int i = 1; i < numberOfMonsters; i++) // Not starting at zero. Player is in room zero. { Point randomRoomLocation = map.GetRandomWalkableLocationInRoom(segment.BBox); // Find a random walkable location in the room to place the monster if (randomRoomLocation != Point.Zero) // It's possible that the room doesn't have space to place a monster { // In that case skip creating the monster var monster = MonsterGenerator.GetDepthAppropriateMonster(game, GameData.Data.Difficulty); // Temporarily hard code this monster to be created at level 1 monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; map.AddMonster(monster); } } } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster if (randomRoomLocation != null) { // Temporarily hard code this monster to be created at level 1 var kobold = Kobold.Create(1); kobold.X = randomRoomLocation.X; kobold.Y = randomRoomLocation.Y; _map.AddMonster(kobold); var goblin = Goblin.Create(2); goblin.X = randomRoomLocation.X; goblin.Y = randomRoomLocation.Y; _map.AddMonster(goblin); } } } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { //Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { //Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { //Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != null) { //Hard code the monster created at level 1 var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // if room doesnt have space, skip creating the monster if (randomRoomLocation != null) { // hard coded to be created at level 1 //map generator will need to know the level of map its creating. var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
private void PlaceMonsters() { // TODO: fix faultyPoint. Probably insecure and should be a null value Point faultyPoint = new Point(-10000, -10000); foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") < 7) { var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != faultyPoint) { var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
/// <summary> /// The algorithm will basically go through each room and roll a 10-sided die. /// If the result of the roll is 1-6 then we’ll roll 4-sided die and add that many monsters to the room in any open Cells. /// </summary> private void PlaceMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D3"); for (int i = 0; i < numberOfMonsters; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster, and the default point that // GetRandomWalkableLocationInRoom() returns in 0, 0. A wall will be there, // so we know that means it's incorrect. if (randomRoomLocation.X != 0 && randomRoomLocation.Y != 0) { // Temporarily hard code this monster to be created at level 1 var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
// Method to place monsters on the map. private void PlaceMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { if (_map.DoesRoomHaveWalkableSpace(room)) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomLocationInRoom(room); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster if (randomRoomLocation != null) { _map.AddMonster(ActorGenerator.CreateMonster(_level, _map.GetRandomLocationInRoom(room))); } } } } } }
// Creating the final level of the game // Killing the final boss will end the game // So there is no need to create stairs down public DungeonMap CreateFinalLevel(SchedulingSystem schedule) { map.Initialize(width, height); Rectangle playerSpawn = new Rectangle(10, height / 2 - 5, 8, 8); Rectangle bossSpawn = new Rectangle(width / 2, 0, width / 2 - 1, height - 2); List <ICell> playerRoom = new List <ICell>(); List <ICell> bossRoom = new List <ICell>(); for (int i = playerSpawn.X; i < playerSpawn.X + playerSpawn.Width; i++) { for (int j = playerSpawn.Y; j < playerSpawn.Y + playerSpawn.Height; j++) { map.SetCellProperties(i, j, true, true, false); playerRoom.Add(map.GetCell(i, j)); } } for (int i = bossSpawn.X; i < bossSpawn.X + bossSpawn.Width; i++) { for (int j = bossSpawn.Y; j < bossSpawn.Y + bossSpawn.Height; j++) { map.SetCellProperties(i, j, true, true, false); bossRoom.Add(map.GetCell(i, j)); } } for (int i = playerSpawn.Center.X; i < bossSpawn.Center.X; i++) { map.SetCellProperties(i, playerSpawn.Center.Y, true, true, false); } map.Rooms.Add(playerRoom); map.Rooms.Add(bossRoom); PlacePlayer(); var dragon = Dragon.Create(1); dragon.X = bossSpawn.Center.X; dragon.Y = bossSpawn.Center.Y; map.AddMonster(dragon); CreateStairs(); // Setting the second stairs at 0,0 to avoid exception map.StairsDown.X = map.StairsDown.Y = 0; return(map); }
private void GenerateMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 3) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // 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) { // Temporarily hard code this monster to be created at level 1 var monster = Prototypes.Monsters.Shade(); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster, false); } } } } var room1 = _map.Rooms.First(); var numberOfMonsters1 = Dice.Roll("1D1"); for (int i = 0; i < 1; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room1); // 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) { // Temporarily hard code this monster to be created at level 1 Monster monster = Prototypes.Monsters.Shade(); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster, false); } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") < 7) { var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != null) { var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
public bool Act(Monster monster, CommandSystem commandSystem) { DungeonMap map = RogueGame.DungeonMap; // Ooze only splits when wounded if (monster.Health >= monster.MaxHealth) { return(false); } int halfHealth = monster.MaxHealth / 2; if (halfHealth <= 0) { // Health would be too low so bail out return(false); } Cell cell = FindClosestUnoccupiedCell(map, monster.X, monster.Y); if (cell == null) { // No empty cells so bail out return(false); } // Make a new ooze with half the health of the old one Ooze newOoze = Monster.Clone(monster) as Ooze; if (newOoze != null) { newOoze.TurnsAlerted = 1; newOoze.X = cell.X; newOoze.Y = cell.Y; newOoze.MaxHealth = halfHealth; newOoze.Health = halfHealth; map.AddMonster(newOoze); RogueGame.MessageLog.Add($"{monster.Name} splits itself in two"); } else { // Not an ooze so bail out return(false); } // Halve the original ooze's health too monster.MaxHealth = halfHealth; monster.Health = halfHealth; return(true); }
private void PlaceMonsters() { int roomNumber = 0; foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") < 6 + (_level / 3)) { var numberOfMonsters = Dice.Roll("1D2") + (_level / 2); for (int i = 0; i < numberOfMonsters; i++) { if (_map.DoesRoomHaveWalkableSpace(room) && roomNumber != 0) { Point randomRoomLocation = _map.GetRandomLocationInRoom(room); if (randomRoomLocation != null) { _map.AddMonster(ActorGenerator.CreateMonster(_level, _map.GetRandomLocationInRoom(room))); } } } } roomNumber++; } }
public void PlaceBoss(DungeonMap map, List <Rectangle> rooms) { int roomIndex = GenerateRandomInt(0, rooms.Count); Console.WriteLine(roomIndex); Rectangle room = rooms[roomIndex]; Point randomRoomLocation = map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != null) { // Temporarily hard code this monster to be created at level 1 var boss = Outlaw.Create(1); boss.X = randomRoomLocation.X; boss.Y = randomRoomLocation.Y; map.AddMonster(map, boss); } }
public void PlaceMonsters(DungeonMap map, Rectangle room) { // Each room has a 60% chance of having monsters //if (Dice.Roll("1D10") < 7) //{ // // Generate between 1 and 4 monsters // var numberOfMonsters = Dice.Roll("1D4"); // for (int i = 0; i < numberOfMonsters; i++) // { // // Find a random walkable location in the room to place the monster // Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // // It's possible that the room doesn't have space to place a monster // // In that case skip creating the monster // if (randomRoomLocation != null) // { // // Temporarily hard code this monster to be created at level 1 // var monster = Kobold.Create(1); // monster.X = randomRoomLocation.X; // monster.Y = randomRoomLocation.Y; // _map.AddMonster(_map, monster); // } // } //} if (test == true) { // Generate between 1 and 4 monsters var numberOfMonsters = 1; for (int i = 0; i < numberOfMonsters; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = map.GetRandomWalkableLocationInRoom(room); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster if (randomRoomLocation != null) { // Temporarily hard code this monster to be created at level 1 var monster = Goon.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; map.AddMonster(map, monster); } } } }
public bool Act(Monster monster, CommandSystem commandSystem) { DungeonMap map = Game.DungeonMap; if (monster.Health >= monster.MaxHealth) { return(false); } int halfHealth = monster.MaxHealth / 2; if (halfHealth <= 0) { return(false); } ICell cell = FindClosestUnoccupiedCell(map, monster.X, monster.Y); if (cell == null) { return(false); } if (Monster.CloneSludge(monster) is Sludge newSludge) { newSludge.TurnsAlerted = 1; newSludge.X = cell.X; newSludge.Y = cell.Y; newSludge.MaxHealth = halfHealth; newSludge.Health = halfHealth; map.AddMonster(newSludge); Game.MessageLog.Add($"{monster.Name} splits itself in two"); } else { return(false); } monster.MaxHealth = halfHealth; monster.Health = halfHealth; return(true); }
// Places monsters all over the dungeon level // Change later so monsters don't spawn in spawn room? or at least not on first level? private void PlaceMonsters() { foreach (var room in _map.Rooms) { // Each room has a 60% chance of having monsters if (Dice.Roll("1D10") < 7) { // Generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { // Find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); // It's possible that the room doesn't have space to place a monster // In that case skip creating the monster if (randomRoomLocation != null) { var typeOfMonster = Dice.Roll("2D10"); var monster = new Monster(); if (typeOfMonster <= 10) { monster = Kobold.Create(_mapLevel); } else if (typeOfMonster > 12) { monster = Goblin.Create(_mapLevel); } else if (typeOfMonster > 10 && typeOfMonster <= 12) { monster = Mimic.Create(_mapLevel); }// Add more monsters later monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { //each room has 60% chance of having monsters if (Dice.Roll("1D10") < 7) { //generate between 1 and 4 monsters var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { //point to a random walkable location and add a monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != null) { var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
//this method goes through each room and rolls a 10-sided die. //if the result of thr roll is 1 - 7 we'll roll 4 sided die and //add that many monsters too that particular room in any open cells private void PlaceMonsters() { foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") < 8) { var numberOfMonsters = Dice.Roll("1D3"); //start i at 1 because we dont want monsters in first room we enter for (int i = 1; i < numberOfMonsters; i++) { Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); if (randomRoomLocation != null) { var monster = Drowner.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
private void PlaceMonsters() { foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") < 7) { var numberOfMonsters = Dice.Roll("1D4"); for (int i = 0; i < numberOfMonsters; i++) { //find a random walkable location in the room to place the monster Point randomRoomLocation = _map.GetRandomWalkableLocationInRoom(room); //it's possible that the room doesn't have space to place a monster //in that case we should skip creating it if (randomRoomLocation != new Point(-1, -1)) { var monster = Kobold.Create(1); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } }
private void PlaceMobs() { for (Rectangle room = iterator.First(); !iterator.IsDone; room = iterator.Next()) //foreach (var room in _map.Rooms) { Random pickupRandomizeCount = new Random(); int pickupCount = pickupRandomizeCount.Next(3); Pickup pickup; if (pickupCount != 0) { for (int i = 0; i < pickupCount; i++) { Point randomPickupPoint = _map.GetRandomFreeTile(room); if (randomPickupPoint != null && _map.GetPickupAt(randomPickupPoint.X, randomPickupPoint.Y) == null) { int roll = Dice.Roll("1D5"); switch (roll) { case 1: { pickup = PickupFactory.GetInstance().getPickup(PickupType.DEF_POTION); break; } case 2: { pickup = PickupFactory.GetInstance().getPickup(PickupType.STR_POTION); break; } case 3: { pickup = PickupFactory.GetInstance().getPickup(PickupType.EXP_POTION); break; } case 4: { pickup = PickupFactory.GetInstance().getPickup(PickupType.GOLD_COIN); break; } case 5: { pickup = PickupFactory.GetInstance().getPickup(PickupType.HP_POTION); break; } default: { pickup = PickupFactory.GetInstance().getPickup(PickupType.GOLD_COIN); break; } } //GoldCoin pickup = new GoldCoin(); //pickup.X = randomPickupPoint.X; //pickup.Y = randomPickupPoint.Y; _map.AddPickup(randomPickupPoint, pickup); } } } if (Dice.Roll("1D10") < 7) { var numberOfMonsters = Dice.Roll("1D4"); if (Game.DanteMustDie) { numberOfMonsters = 7; } else if (Game.KoboldKarnage) { numberOfMonsters = room.Height * room.Width - 10; } if (numberOfMonsters < 1) { numberOfMonsters = 1; } for (int i = 0; i < numberOfMonsters; i++) { CreationType type; var typeDecider = Dice.Roll("1D100"); if (typeDecider <= 60) { type = CreationType.NORMAL; } else if (typeDecider <= 80) { type = CreationType.WEAK; } else if (typeDecider <= 92) { type = CreationType.MINI_BOSS; } else { type = CreationType.BOSS; } Point randomRoomLocation = _map.GetRandomFreeTile(room); if (randomRoomLocation != null) { int level = Player.GetInstance().Level + Facade._mapLevel + Dice.Roll("1D5") - Dice.Roll("1D5"); if (level < 1) { level = 1; } int whatMonster = Dice.Roll("1D100"); if (Game.KoboldKarnage) { whatMonster = 1; } if (whatMonster <= 25) { Monster monster = MonsterFactoryStore.getFactory(FactoryType.KOBOLD).Create(type); monster.SetAttributes(level); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } else if (whatMonster <= 50) { Monster monster = MonsterFactoryStore.getFactory(FactoryType.ORC).Create(type); monster.SetAttributes(level); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } else if (whatMonster <= 90) { Monster monster = MonsterFactoryStore.getFactory(FactoryType.GOBLIN).Create(type); monster.SetAttributes(level); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } else if (whatMonster <= 95) { Monster monster = MonsterFactoryStore.getFactory(FactoryType.BEHOLDER).Create(type); monster.SetAttributes(level); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } else if (whatMonster <= 100) { Monster monster = MonsterFactoryStore.getFactory(FactoryType.GOBLIN_SHAMAN).Create(type); monster.SetAttributes(level); monster.X = randomRoomLocation.X; monster.Y = randomRoomLocation.Y; _map.AddMonster(monster); } } } } } }