Started with interiorGeneration() WIP
feel free to continie
This commit is contained in:
parent
cb8425f9e1
commit
ef8c54e9a0
2 changed files with 47 additions and 0 deletions
|
@ -17,6 +17,9 @@ public class DungeonGenerator {
|
||||||
// All rooms except the three above
|
// All rooms except the three above
|
||||||
public HashSet<GenRoom> rooms;
|
public HashSet<GenRoom> rooms;
|
||||||
|
|
||||||
|
private const float percentageRocks = 0.03;
|
||||||
|
private const int maxRockCluster = 5;
|
||||||
|
|
||||||
public void Generate() {
|
public void Generate() {
|
||||||
int minRoomSize = 50;
|
int minRoomSize = 50;
|
||||||
rooms = new HashSet<GenRoom>();
|
rooms = new HashSet<GenRoom>();
|
||||||
|
@ -149,6 +152,12 @@ public class DungeonGenerator {
|
||||||
r.tiles[v] = Room.TileType.DOOR;
|
r.tiles[v] = Room.TileType.DOOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (GenRoom r in rooms) {
|
||||||
|
generateInterior (r);
|
||||||
|
}
|
||||||
|
|
||||||
|
rooms.Add(path);
|
||||||
|
|
||||||
start = root.r;
|
start = root.r;
|
||||||
end = null; foreach ( GenRoom r in rooms ) {
|
end = null; foreach ( GenRoom r in rooms ) {
|
||||||
if ( end == null || r.bounds.x > end.bounds.x )
|
if ( end == null || r.bounds.x > end.bounds.x )
|
||||||
|
@ -344,4 +353,38 @@ public class DungeonGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void generateInterior(GenRoom r)
|
||||||
|
{
|
||||||
|
int width = r.bounds.width;
|
||||||
|
int height = r.bounds.height;
|
||||||
|
|
||||||
|
Vector2Int root = new Vector2Int (1, 1);
|
||||||
|
Random rand = new Random (System.DateTime.Now);
|
||||||
|
|
||||||
|
for(int x = 0; i != width; ++x)
|
||||||
|
{
|
||||||
|
for(int y = 0; y != width; ++y)
|
||||||
|
{
|
||||||
|
Room.TileType tempTile;
|
||||||
|
r.tiles.TryGetValue (root + new Vector2Int (x, y), tempTile);
|
||||||
|
|
||||||
|
if(rand.NextDouble() <= percentageRocks && tempTile.Equals(Room.TileType.GROUND)
|
||||||
|
{
|
||||||
|
int clusterSize = rand.Next (1, maxRockCluster + 1);
|
||||||
|
r.tiles.Add (root + new Vector2Int (x, y), Room.TileType.ROCK);
|
||||||
|
|
||||||
|
for(int i = 0; i != clusterSize; ++i)
|
||||||
|
{
|
||||||
|
Vector2Int newRock = root + new Vector2Int(x + rand.Next(0, 2), y + rand.Next(0, 2));
|
||||||
|
r.tiles.TryGetValue (newRock, tempTile);
|
||||||
|
if(!tempTile.Equals(Room.TileType.GROUND))
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -35,4 +35,8 @@ public class GenRoom {
|
||||||
ret.UnionWith(doorsRight);
|
ret.UnionWith(doorsRight);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void generateInteror()
|
||||||
|
{
|
||||||
|
b
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue