Implemented boss room generation and adding to the dungeon.
This commit is contained in:
parent
5f2be1333b
commit
8ed53b6384
2 changed files with 32 additions and 6 deletions
|
|
@ -12,11 +12,15 @@ namespace DungeonGenerator
|
||||||
{
|
{
|
||||||
private const int SIDE_LENGTH_OF_MONSTER = 4;
|
private const int SIDE_LENGTH_OF_MONSTER = 4;
|
||||||
private const int SIDE_LENGTH_OF_NORMAL = 2;
|
private const int SIDE_LENGTH_OF_NORMAL = 2;
|
||||||
|
private const int WIDTH_OF_BOSS = 10;
|
||||||
|
private const int HEIGHT_OF_BOSS = 6;
|
||||||
|
|
||||||
private List<Room> _monsterRooms = new List<Room>();
|
|
||||||
private int _xLength = 40;
|
private int _xLength = 40;
|
||||||
private int _yLength = 28;
|
private int _yLength = 28;
|
||||||
private List<Point> _entrancePoints;
|
|
||||||
|
private List<Room> _monsterRooms = new List<Room>();
|
||||||
|
private List<Room> _entranceRooms;
|
||||||
|
private Room _bossRoom;
|
||||||
|
|
||||||
public void GenerateDungeon(int length, float monsterRoomRatio)
|
public void GenerateDungeon(int length, float monsterRoomRatio)
|
||||||
{
|
{
|
||||||
|
|
@ -24,10 +28,15 @@ namespace DungeonGenerator
|
||||||
_yLength = 28;
|
_yLength = 28;
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
List<Room> entranceRooms = GenerateEntranceRooms(_xLength, _yLength, random.Next(1,4));
|
List<Point> pointsToExclude = new List<Point>();
|
||||||
_entrancePoints = entranceRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
|
|
||||||
|
|
||||||
EvenDisperser disperser = new EvenDisperser(_xLength, _yLength, _entrancePoints); //TODO calculate L and W from length
|
_entranceRooms = GenerateEntranceRooms(_xLength, _yLength, random.Next(1,4));
|
||||||
|
pointsToExclude.AddRange(_entranceRooms.SelectMany(room => room.GetPointsInRoom()).ToList());
|
||||||
|
|
||||||
|
_bossRoom = GenerateOnlyBossRoom(_xLength, _yLength, WIDTH_OF_BOSS, HEIGHT_OF_BOSS);
|
||||||
|
pointsToExclude.AddRange(_bossRoom.GetPointsInRoom());
|
||||||
|
|
||||||
|
EvenDisperser disperser = new EvenDisperser(_xLength, _yLength, pointsToExclude); //TODO calculate L and W from length
|
||||||
int numberOfMonsterRooms = 7; // TODO: Calculate from ratio
|
int numberOfMonsterRooms = 7; // TODO: Calculate from ratio
|
||||||
|
|
||||||
for (var i = 0; i < numberOfMonsterRooms; i ++)
|
for (var i = 0; i < numberOfMonsterRooms; i ++)
|
||||||
|
|
@ -42,12 +51,13 @@ namespace DungeonGenerator
|
||||||
public void PrintMap()
|
public void PrintMap()
|
||||||
{
|
{
|
||||||
List<Point> monsterRoomPoints = _monsterRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
|
List<Point> monsterRoomPoints = _monsterRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
|
||||||
|
List<Point> entranceRoomPoints = _entranceRooms.SelectMany(room => room.GetPointsInRoom()).ToList();
|
||||||
char[,] mapMatrix = new Char[_xLength, _yLength];
|
char[,] mapMatrix = new Char[_xLength, _yLength];
|
||||||
for (int x = 0; x < _xLength; x++)
|
for (int x = 0; x < _xLength; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < _yLength; y++)
|
for (int y = 0; y < _yLength; y++)
|
||||||
{
|
{
|
||||||
if (_entrancePoints.Contains(new Point(x, y)))
|
if (entranceRoomPoints.Contains(new Point(x, y)))
|
||||||
{
|
{
|
||||||
mapMatrix[x, y] = '*';
|
mapMatrix[x, y] = '*';
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +65,10 @@ namespace DungeonGenerator
|
||||||
{
|
{
|
||||||
mapMatrix[x, y] = 'X';
|
mapMatrix[x, y] = 'X';
|
||||||
}
|
}
|
||||||
|
else if (_bossRoom.GetPointsInRoom().Contains(new Point(x, y)))
|
||||||
|
{
|
||||||
|
mapMatrix[x, y] = 'B';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mapMatrix[x, y] = '-';
|
mapMatrix[x, y] = '-';
|
||||||
|
|
@ -79,6 +93,17 @@ namespace DungeonGenerator
|
||||||
sb.ToString());
|
sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Room GenerateOnlyBossRoom(int xLengthOfDungeon, int yLengthOfDungeon, int width, int heigth)
|
||||||
|
{
|
||||||
|
// Place monster room in the middle third
|
||||||
|
int middleAreaX = xLengthOfDungeon / 3;
|
||||||
|
int middleAreaY = yLengthOfDungeon / 3;
|
||||||
|
Random random = new Random();
|
||||||
|
int bossX = middleAreaX + random.Next(0, middleAreaX - width);
|
||||||
|
int bossY = middleAreaY + random.Next(0, middleAreaY - heigth);
|
||||||
|
return new Room(RoomType.Boss, width, heigth, new Point(bossX, bossY));
|
||||||
|
}
|
||||||
|
|
||||||
private enum Side
|
private enum Side
|
||||||
{
|
{
|
||||||
Top,
|
Top,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace DungeonGenerator
|
||||||
Normal,
|
Normal,
|
||||||
Entrance,
|
Entrance,
|
||||||
Monster,
|
Monster,
|
||||||
|
Boss
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue