1
0
Fork 0

Even better walls

This commit is contained in:
Piegames 2018-04-23 00:27:44 +02:00
parent c26844f74b
commit 336b57ae4e
3 changed files with 47 additions and 27 deletions

View file

@ -156,15 +156,35 @@ public class DungeonGenerator {
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);
Vector2Int pos2 = new Vector2Int(x1 + 1, y1);
if (!path.tiles.ContainsKey(pos2) && !allDoors.Contains(pos2))
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL));
}
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");

View file

@ -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;

View file

@ -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;