Implemented number population

This commit is contained in:
Max 2025-02-18 18:00:36 +01:00
parent fd1700d650
commit 2f1b2d49b3
21 changed files with 10030 additions and 18173 deletions

View file

@ -378,7 +378,7 @@ namespace DungeonMapGenerator
throw new Exception("Number of entrance lines cannot be greater than 4");
}
const int numEntranceRooms = 12;
const int numEntranceRooms = 11;
List<Room> entranceRooms = new List<Room>();
Random random = new Random();
Dictionary<Side, int> sidesToEnterOn = new Dictionary<Side, int>()

View file

@ -64,18 +64,35 @@ namespace DungeonMapGenerator
pregeneratedLocks.Add(room.Lock);
}
if (locklessRooms.Count > 0)
if (locklessRooms.Count > 3)
{
// Add locks to the rooms with odds adding to within the difficulty range
// Add locks to the rooms with odds adding to the desired success chance
List<Lock> locks = GenerateLocks(pregeneratedLocks, locklessRooms.Count, desiredSuccessChance);
for (int i = 0; i < locklessRooms.Count; i++)
{
locklessRooms[i].Lock = locks[i];
}
}
else if (locklessRooms.Count > 0)
{
foreach (Room room in locklessRooms)
{
room.Lock = Lock.PossibleLocks[random.Next(0, Lock.PossibleLocks.Count)];
}
}
currentRooms = adjacentRooms;
}
// Check if all locks were set
foreach (var room in dungeon.GetAllRooms())
{
if (room.Lock == null)
{
Console.WriteLine($"Room at {room.GetCenterOfRoom()} wasn't seen whilst populating locks");
room.Lock = Lock.PossibleLocks[random.Next(0, Lock.PossibleLocks.Count)];
}
}
}
private static List<Lock> GenerateLocks(List<Lock> pregeneratedLocks, int numLocks, float successChance)

View file

@ -134,17 +134,33 @@ namespace DungeonMapGenerator
}
public string GetMapAsString()
{
return GetMapAsString(null);
}
public string GetMapAsString(List<Room> roomsToHighlight)
{
List<Point> monsterRoomPoints = _monsterRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
List<Point> entranceRoomPoints = _entranceRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
List<Point> normalRoomPoints = _normalRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
List<Point> highlightRoomPoints = new List<Point>();
if (roomsToHighlight != null)
{
highlightRoomPoints = roomsToHighlight.SelectMany(room => room.GetPointsInRoom()).ToList();
}
char[,] mapMatrix = new Char[Width, Height];
for (int x = 0; x < Width; x++)
{
for (int y = 0; y < Height; y++)
{
Point point = new Point(x, y);
if (entranceRoomPoints.Contains(point))
if (highlightRoomPoints.Contains(point))
{
mapMatrix[x, y] = 'O';
}
else if (entranceRoomPoints.Contains(point))
{
mapMatrix[x, y] = '*';
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff