Implemented generation of room rewards
This commit is contained in:
parent
807656b112
commit
57f6ee51e1
8 changed files with 75 additions and 8 deletions
|
|
@ -13,10 +13,15 @@ class Program
|
||||||
var generator = new DungeonGenerator();
|
var generator = new DungeonGenerator();
|
||||||
|
|
||||||
// Call the method you want to run
|
// Call the method you want to run
|
||||||
int width = 100;
|
int width = 40;
|
||||||
int height = 50;
|
int height = 28;
|
||||||
DungeonMap map = generator.GenerateDungeon(width, height, 5);
|
DungeonMap map = generator.GenerateDungeon(width, height, 5);
|
||||||
DungeonLockPopulator.PopulateLocksOfDungeon(map);
|
DungeonLockPopulator.PopulateLocksOfDungeon(map);
|
||||||
|
List<Room> potentialLootRooms = new List<Room>();
|
||||||
|
potentialLootRooms.AddRange(map.GetNormalRooms());
|
||||||
|
potentialLootRooms.AddRange(map.GetMonsterRooms());
|
||||||
|
potentialLootRooms.Add(map.GetBossRoom());
|
||||||
|
DungeonLootPopulator.GenerateLootInRooms(potentialLootRooms);
|
||||||
DungeonMapSerializer.SerializeToFile(map, SAVED_DUNGEONS_PATH, $"{DUNGEON_NAME} {width}x{height}" );
|
DungeonMapSerializer.SerializeToFile(map, SAVED_DUNGEONS_PATH, $"{DUNGEON_NAME} {width}x{height}" );
|
||||||
|
|
||||||
// Print the map to the console (assuming it returns a string or something printable)
|
// Print the map to the console (assuming it returns a string or something printable)
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -14,8 +14,8 @@ namespace DungeonMapGenerator
|
||||||
private const int WIDTH_OF_BOSS = 10;
|
private const int WIDTH_OF_BOSS = 10;
|
||||||
private const int HEIGHT_OF_BOSS = 6;
|
private const int HEIGHT_OF_BOSS = 6;
|
||||||
|
|
||||||
private int _xLength = 40;
|
private int _xLength;
|
||||||
private int _yLength = 28;
|
private int _yLength;
|
||||||
|
|
||||||
public DungeonMap GenerateDungeon(int xlength, int yLength, int numberOfMonsterRooms)
|
public DungeonMap GenerateDungeon(int xlength, int yLength, int numberOfMonsterRooms)
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +25,7 @@ namespace DungeonMapGenerator
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
DungeonMap dungeonMap = new DungeonMap(_xLength, _yLength);
|
DungeonMap dungeonMap = new DungeonMap(_xLength, _yLength);
|
||||||
|
|
||||||
dungeonMap.AddRooms(GenerateEntranceRooms(_xLength, _yLength, random.Next(1,4)));
|
dungeonMap.AddRooms(GenerateEntranceRooms(_xLength, _yLength, random.Next(1,3)));
|
||||||
dungeonMap.AddRoom(GenerateOnlyBossRoom(_xLength, _yLength, WIDTH_OF_BOSS, HEIGHT_OF_BOSS));
|
dungeonMap.AddRoom(GenerateOnlyBossRoom(_xLength, _yLength, WIDTH_OF_BOSS, HEIGHT_OF_BOSS));
|
||||||
|
|
||||||
EvenDisperser disperser = new EvenDisperser(_xLength, _yLength, dungeonMap.GetUnoccupiedPoints()); //TODO calculate L and W from length
|
EvenDisperser disperser = new EvenDisperser(_xLength, _yLength, dungeonMap.GetUnoccupiedPoints()); //TODO calculate L and W from length
|
||||||
|
|
@ -43,7 +43,7 @@ namespace DungeonMapGenerator
|
||||||
AddConnectionRooms(dungeonMap);
|
AddConnectionRooms(dungeonMap);
|
||||||
ConnectAllAdjacentRooms(dungeonMap);
|
ConnectAllAdjacentRooms(dungeonMap);
|
||||||
AddAdjacentRoomsToEntranceRooms(dungeonMap);
|
AddAdjacentRoomsToEntranceRooms(dungeonMap);
|
||||||
|
|
||||||
return dungeonMap;
|
return dungeonMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace DungeonMapGenerator
|
||||||
|
{
|
||||||
|
public static class DungeonLootPopulator
|
||||||
|
{
|
||||||
|
private const int MONSTER_ROOM_DIAMONDS = 2;
|
||||||
|
private const int BOSS_ROOM_DIAMONDS = 6;
|
||||||
|
private const int BOSS_ROOM_DAMAGE = 2;
|
||||||
|
|
||||||
|
public static void GenerateLootInRooms(List<Room> rooms)
|
||||||
|
{
|
||||||
|
foreach (Room room in rooms)
|
||||||
|
{
|
||||||
|
switch (room.TypeOfRoom)
|
||||||
|
{
|
||||||
|
case RoomType.Normal:
|
||||||
|
if (Lock.HardLocks.Any(l => l.GetLock() == room.Lock.GetLock()))
|
||||||
|
{
|
||||||
|
room.AddLoot(LootType.Chest);
|
||||||
|
}
|
||||||
|
else if (Lock.VeryHardLocks.Any(l => l.GetLock() == room.Lock.GetLock()))
|
||||||
|
{
|
||||||
|
room.AddLoot(LootType.Diamond);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RoomType.Monster:
|
||||||
|
for (int i = 0; i < MONSTER_ROOM_DIAMONDS; i++)
|
||||||
|
{
|
||||||
|
room.AddLoot(LootType.Diamond);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RoomType.Boss:
|
||||||
|
for (int i = 0; i < BOSS_ROOM_DIAMONDS; i++)
|
||||||
|
{
|
||||||
|
room.AddLoot(LootType.Diamond);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < BOSS_ROOM_DAMAGE; i++)
|
||||||
|
{
|
||||||
|
room.AddLoot(LootType.Diamond);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,13 @@ namespace DungeonMapGenerator
|
||||||
Monster,
|
Monster,
|
||||||
Boss
|
Boss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LootType
|
||||||
|
{
|
||||||
|
Diamond,
|
||||||
|
Chest,
|
||||||
|
Damage
|
||||||
|
}
|
||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +39,8 @@ namespace DungeonMapGenerator
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public Point PositionOfTopLeft { get; set; }
|
public Point PositionOfTopLeft { get; set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[JsonProperty("Loot")]
|
||||||
|
private List<LootType> _loot = new List<LootType>();
|
||||||
[JsonProperty("AdjacentRoomIds")]
|
[JsonProperty("AdjacentRoomIds")]
|
||||||
private HashSet<int> _adjacentRoomIds = new HashSet<int>();
|
private HashSet<int> _adjacentRoomIds = new HashSet<int>();
|
||||||
private HashSet<Room> _adjacentRooms = new HashSet<Room>();
|
private HashSet<Room> _adjacentRooms = new HashSet<Room>();
|
||||||
|
|
@ -57,8 +65,12 @@ namespace DungeonMapGenerator
|
||||||
_adjacentRooms.Add(room);
|
_adjacentRooms.Add(room);
|
||||||
_adjacentRoomIds.Add(room.Id);
|
_adjacentRoomIds.Add(room.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AddLoot(LootType loot)
|
||||||
|
{
|
||||||
|
_loot.Add(loot);
|
||||||
|
}
|
||||||
|
|
||||||
public HashSet<int> GetAdjacentRoomIds()
|
public HashSet<int> GetAdjacentRoomIds()
|
||||||
{
|
{
|
||||||
return new HashSet<int>(_adjacentRoomIds);
|
return new HashSet<int>(_adjacentRoomIds);
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue