Beispiel #1
0
 private void PlaceVillagers(DungeonMap map, Rectangle room)
 {
     if (test == true)
     {
         // Generate between 1 and 4 monsters
         var numberOfTownspeople = 20;
         for (int i = 0; i < numberOfTownspeople; 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 villager = Villager.Create(1);
                 villager.X = randomRoomLocation.X;
                 villager.Y = randomRoomLocation.Y;
                 map.AddVillager(map, villager);
             }
         }
     }
 }