So, I have went through dozens of the answers already in the forum and watched every tutorial I can locate. I can’t seem to get my Unity to do what it does in the videos. I’ve landed on the conclusion that its either me failing miserably or something to do with the different versions that the person and I am using.
In Visual Studio, I have all the code to make an old school *, &, @, # kind of dungeon but no idea how to combine the two. The way I have it now, it makes a blank board of a given character, then iterates through the blank board generating random rooms, checking to make sure they fit, and if they do, iterate back through and create the room. Super Basic.
//Creating a blank board
for (int i = x - 1; i >= 0; i--)
{
for (int j = y - 1; j >= 0; j--)
{
board[i, j] = new Tile("▓", ConsoleColor.DarkGreen);
}
}
//Gathers room sizes for checking
for (int i = 0; i <= 11; i++)
{
int roomX = StaticRandom.Instance.Next(1, height -2);
int roomHeight = StaticRandom.Instance.Next(roomX +1, height - 2);
int roomY = StaticRandom.Instance.Next(1, length - 2);
int roomLength = StaticRandom.Instance.Next(roomY +1, length - 1);
bool result = CheckRoom(roomX, roomY, roomHeight, roomLength);
if (result == false)
{
i--; continue;
}
else
{
MakeRoom(roomX, roomY, roomHeight, roomLength);
}
}
}
public bool CheckRoom(int x, int y, int h, int l)
{
for (int i = x; i <= h; i++) {
for (int j = y; j <= l; j++)
{
if (board[i, j].symbol != "▓")
{
return false;
}
}
}
return true;
}
//iterate through the blank board and changes spaces to create 'rooms'
public void MakeRoom(int x, int y, int h, int l)
{ int midX = (x + h) / 2;
int midY = (l + y) / 2;
for (int i = x; i <= h; i++)
{
for (int j = y; j <= l; j++)
{
board[i, j] = new Tile("░", ConsoleColor.DarkGray);
}
}
midPoints.Add(new int[] { midX, midY });
}
I’ll admit that its incredibly possible that this question has been answered, but there are SO many answers and I didn’t have any luck going through them.