Rotation for straight wall
This commit is contained in:
parent
b13a13cfde
commit
ede4f74a3a
4 changed files with 55 additions and 15 deletions
|
@ -127,7 +127,9 @@ public class DungeonGenerator {
|
|||
foreach ( GenRoom r in rooms ) {
|
||||
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++ ) {
|
||||
r.tiles.Add(new Vector2Int(x1, y1), new GenTile(Room.TileType.WALL));
|
||||
int xMode = (x1 == r.bounds.x) ? -1 : (x1 == r.bounds.x + r.bounds.width - 1) ? 1 : 0;
|
||||
int yMode = (y1 == r.bounds.y) ? -1 : (y1 == r.bounds.y + r.bounds.height - 1) ? 1 : 0;
|
||||
r.tiles.Add(new Vector2Int(x1, y1), new GenTile(Room.TileType.WALL, GenTile.GetPosition(xMode,yMode)));
|
||||
}
|
||||
for ( int x1 = r.bounds.x + 1; x1 < r.bounds.x + r.bounds.width - 1; x1++ )
|
||||
for ( int y1 = r.bounds.y + 1; y1 < r.bounds.y + r.bounds.height - 1; y1++ ) {
|
||||
|
@ -155,6 +157,7 @@ public class DungeonGenerator {
|
|||
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);
|
||||
|
@ -162,6 +165,7 @@ public class DungeonGenerator {
|
|||
path.tiles.Add(pos2, new GenTile(Room.TileType.WALL));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r.AllDoors().Count > 0)
|
||||
throw new NotSupportedException("Paths should not have any doors");
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
|||
|
||||
public class GenRoom {
|
||||
// ---Internal for generation only---
|
||||
// TODO make them package protcted please
|
||||
// TODO make them package protected please
|
||||
|
||||
public RectInt bounds = new RectInt();
|
||||
public HashSet<Vector2Int> doorsUp = new HashSet<Vector2Int>();
|
||||
|
|
|
@ -6,8 +6,17 @@ public class GenTile
|
|||
{
|
||||
public enum Position
|
||||
{
|
||||
TOP, BOTTOM, LEFT, RIGHT, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT
|
||||
TOP_LEFT = 0,
|
||||
TOP = 1,
|
||||
TOP_RIGHT = 2,
|
||||
LEFT = 3,
|
||||
CENTER = 4,
|
||||
RIGHT = 5,
|
||||
BOTTOM_LEFT = 6,
|
||||
BOTTOM = 7,
|
||||
BOTTOM_RIGHT = 8
|
||||
}
|
||||
|
||||
public Room.TileType type;
|
||||
public Position position;
|
||||
|
||||
|
@ -16,7 +25,18 @@ public class GenTile
|
|||
|
||||
}
|
||||
|
||||
public GenTile(Room.TileType type) {
|
||||
public GenTile(Room.TileType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public GenTile(Room.TileType type, Position position)
|
||||
{
|
||||
this.type = type;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public static Position GetPosition(int xMode, int yMode) {
|
||||
return (Position) ((xMode + 1) + (yMode + 1) * 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,22 @@ public class GenerationProcessor {
|
|||
type = ExtendedTileType.BorderInner;
|
||||
} else {
|
||||
// BorderSingle
|
||||
if (tiles[v].position != null) {
|
||||
switch (tiles[v].position) {
|
||||
case GenTile.Position.BOTTOM:
|
||||
rotation = 0;
|
||||
break;
|
||||
case GenTile.Position.LEFT:
|
||||
rotation = 90;
|
||||
break;
|
||||
case GenTile.Position.TOP:
|
||||
rotation = 180;
|
||||
break;
|
||||
case GenTile.Position.RIGHT:
|
||||
rotation = 270;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Room.TileType.GROUND:
|
||||
|
|
Loading…
Add table
Reference in a new issue