Fixed doors and wall generation
This commit is contained in:
parent
c5aa4cdf5b
commit
59fbc56a55
1 changed files with 25 additions and 18 deletions
|
@ -123,24 +123,7 @@ public class DungeonGenerator {
|
||||||
AddCurve(rooms2, ed);
|
AddCurve(rooms2, ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = new GenRoom();
|
HashSet<Vector2Int> allDoors = new HashSet<Vector2Int>();
|
||||||
foreach ( GenRoom r in rooms2 ) {
|
|
||||||
for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ )
|
|
||||||
for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) {
|
|
||||||
Vector2Int pos1 = new Vector2Int(x1, y1);
|
|
||||||
if ( path.tiles.ContainsKey(pos1) )
|
|
||||||
path.tiles[pos1] = Room.TileType.GROUND;
|
|
||||||
else
|
|
||||||
path.tiles.Add(pos1, Room.TileType.GROUND);
|
|
||||||
for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ )
|
|
||||||
for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) {
|
|
||||||
if ( !path.tiles.ContainsKey(new Vector2Int(x2, y2)) )
|
|
||||||
path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r.AllDoors().Count > 0)
|
|
||||||
throw new NotSupportedException("Paths should not have any doors");
|
|
||||||
}
|
|
||||||
foreach ( GenRoom r in rooms ) {
|
foreach ( GenRoom r in rooms ) {
|
||||||
for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ )
|
for ( int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++ )
|
||||||
for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) {
|
for ( int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++ ) {
|
||||||
|
@ -150,6 +133,7 @@ public class DungeonGenerator {
|
||||||
for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) {
|
for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) {
|
||||||
r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND;
|
r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND;
|
||||||
}
|
}
|
||||||
|
allDoors.UnionWith(r.AllDoors());
|
||||||
foreach ( Vector2Int v in r.AllDoors() ) {
|
foreach ( Vector2Int v in r.AllDoors() ) {
|
||||||
Debug.Log("Door: " + v);
|
Debug.Log("Door: " + v);
|
||||||
if ( !r.bounds.Contains(v) )
|
if ( !r.bounds.Contains(v) )
|
||||||
|
@ -157,6 +141,29 @@ public class DungeonGenerator {
|
||||||
else
|
else
|
||||||
r.tiles[v] = Room.TileType.DOOR;
|
r.tiles[v] = Room.TileType.DOOR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path = new GenRoom();
|
||||||
|
foreach (GenRoom r in rooms2)
|
||||||
|
{
|
||||||
|
for (int x1 = r.bounds.x; x1 < r.bounds.x + r.bounds.width; x1++)
|
||||||
|
for (int y1 = r.bounds.y; y1 < r.bounds.y + r.bounds.height; y1++)
|
||||||
|
{
|
||||||
|
Vector2Int pos1 = new Vector2Int(x1, y1);
|
||||||
|
if (path.tiles.ContainsKey(pos1))
|
||||||
|
path.tiles[pos1] = Room.TileType.GROUND;
|
||||||
|
else
|
||||||
|
path.tiles.Add(pos1, Room.TileType.GROUND);
|
||||||
|
for (int x2 = x1 - 1; x2 <= x1 + 1; x2++)
|
||||||
|
for (int y2 = y1 - 1; y2 <= y1 + 1; y2++)
|
||||||
|
{
|
||||||
|
Vector2Int pos2 = new Vector2Int(x2, y2);
|
||||||
|
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||||
|
path.tiles.Add(pos2, Room.TileType.WALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (r.AllDoors().Count > 0)
|
||||||
|
throw new NotSupportedException("Paths should not have any doors");
|
||||||
}
|
}
|
||||||
|
|
||||||
//foreach (GenRoom r in rooms) {
|
//foreach (GenRoom r in rooms) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue