Even better walls
This commit is contained in:
parent
c26844f74b
commit
336b57ae4e
3 changed files with 47 additions and 27 deletions
|
@ -147,24 +147,44 @@ public class DungeonGenerator {
|
|||
|
||||
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].type = Room.TileType.GROUND;
|
||||
else
|
||||
path.tiles.Add(pos1, new GenTile(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, new GenTile(Room.TileType.WALL));
|
||||
}
|
||||
}
|
||||
if (path.tiles.ContainsKey(pos1))
|
||||
path.tiles[pos1].type = Room.TileType.GROUND;
|
||||
else
|
||||
path.tiles.Add(pos1, new GenTile(Room.TileType.GROUND));
|
||||
|
||||
Vector2Int pos2 = new Vector2Int(x1 + 1, y1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.RIGHT));
|
||||
pos2 = new Vector2Int(x1 - 1, y1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.LEFT));
|
||||
pos2 = new Vector2Int(x1, y1 + 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.TOP));
|
||||
pos2 = new Vector2Int(x1, y1 - 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.BOTTOM));
|
||||
}
|
||||
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 pos2 = new Vector2Int(x1 + 1, y1 + 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.TOP_RIGHT));
|
||||
pos2 = new Vector2Int(x1 - 1, y1 + 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.TOP_LEFT));
|
||||
pos2 = new Vector2Int(x1 + 1, y1 - 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.BOTTOM_RIGHT));
|
||||
pos2 = new Vector2Int(x1 - 1, y1 - 1);
|
||||
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
|
||||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL, GenTile.Position.BOTTOM_LEFT));
|
||||
}
|
||||
if (r.AllDoors().Count > 0)
|
||||
throw new NotSupportedException("Paths should not have any doors");
|
||||
|
|
|
@ -6,15 +6,15 @@ public class GenTile
|
|||
{
|
||||
public enum Position
|
||||
{
|
||||
TOP_LEFT = 0,
|
||||
TOP = 1,
|
||||
TOP_RIGHT = 2,
|
||||
BOTTOM_LEFT = 0,
|
||||
BOTTOM = 1,
|
||||
BOTTOM_RIGHT = 2,
|
||||
LEFT = 3,
|
||||
CENTER = 4,
|
||||
RIGHT = 5,
|
||||
BOTTOM_LEFT = 6,
|
||||
BOTTOM = 7,
|
||||
BOTTOM_RIGHT = 8
|
||||
TOP_LEFT = 6,
|
||||
TOP = 7,
|
||||
TOP_RIGHT = 8
|
||||
}
|
||||
|
||||
public Room.TileType type;
|
||||
|
|
|
@ -27,13 +27,13 @@ public class GenerationProcessor {
|
|||
switch (tiles[v].position)
|
||||
{
|
||||
case GenTile.Position.BOTTOM:
|
||||
rotation = 0;
|
||||
rotation = 180;
|
||||
break;
|
||||
case GenTile.Position.LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP:
|
||||
rotation = 180;
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.RIGHT:
|
||||
rotation = 270;
|
||||
|
@ -44,16 +44,16 @@ public class GenerationProcessor {
|
|||
switch (tiles[v].position)
|
||||
{
|
||||
case GenTile.Position.BOTTOM_LEFT:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.TOP_LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP_LEFT:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.TOP_RIGHT:
|
||||
rotation = 180;
|
||||
rotation = 270;
|
||||
break;
|
||||
case GenTile.Position.BOTTOM_RIGHT:
|
||||
rotation = 270;
|
||||
rotation = 180;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue