Implemented generation of normal rooms around monster rooms. They still collid with each other.

This commit is contained in:
Max 2025-02-06 14:47:35 +01:00
parent 2cd9df5652
commit e0c65bd66e
3 changed files with 256 additions and 6 deletions

View file

@ -13,6 +13,7 @@ namespace DungeonGenerator
private int _height;
private List<Room> _monsterRooms = new List<Room>();
private List<Room> _entranceRooms = new List<Room>();
private List<Room> _normalRooms = new List<Room>();
private Room _bossRoom;
private HashSet<Point> _unoccupiedPoints = new HashSet<Point>();
@ -35,6 +36,9 @@ namespace DungeonGenerator
case RoomType.Entrance:
_entranceRooms.Add(room);
break;
case RoomType.Normal:
_normalRooms.Add(room);
break;
case RoomType.Boss:
_bossRoom = room;
break;
@ -47,6 +51,8 @@ namespace DungeonGenerator
public void AddRooms(List<Room> rooms)
{
if (rooms.Count == 0) return;
switch (rooms[0].TypeOfRoom)
{
case RoomType.Monster:
@ -55,6 +61,9 @@ namespace DungeonGenerator
case RoomType.Entrance:
_entranceRooms.AddRange(rooms);
break;
case RoomType.Normal:
_normalRooms.AddRange(rooms);
break;
default:
return;
}
@ -77,6 +86,11 @@ namespace DungeonGenerator
return _entranceRooms;
}
public List<Room> GetNormalRooms()
{
return _normalRooms;
}
public HashSet<Point> GetUnoccupiedPoints()
{
return new HashSet<Point>(_unoccupiedPoints);
@ -86,23 +100,29 @@ namespace DungeonGenerator
{
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();
char[,] mapMatrix = new Char[_width, _height];
for (int x = 0; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
if (entranceRoomPoints.Contains(new Point(x, y)))
Point point = new Point(x, y);
if (entranceRoomPoints.Contains(point))
{
mapMatrix[x, y] = '*';
}
else if (monsterRoomPoints.Contains(new Point(x,y)))
else if (monsterRoomPoints.Contains(point))
{
mapMatrix[x, y] = 'X';
}
else if (_bossRoom.GetPointsInRoom().Contains(new Point(x, y)))
else if (_bossRoom.GetPointsInRoom().Contains(point))
{
mapMatrix[x, y] = 'B';
}
else if (normalRoomPoints.Contains(point))
{
mapMatrix[x, y] = 'N';
}
else
{
mapMatrix[x, y] = '-';