1
0
Fork 0

Merge remote-tracking branch 'origin/PiegamesDev'

This commit is contained in:
Saibotk 2018-04-22 21:04:06 +02:00
commit 75917b6e17
2 changed files with 38 additions and 25 deletions

View file

@ -39,7 +39,7 @@ public class Door : MonoBehaviour {
locked = true;
boundingBox.enabled = true;
triggerBox.enabled = false;
GetComponent<SpriteRenderer>().enabled = true;
//GetComponent<SpriteRenderer>().enabled = true;
}
/// <summary>
@ -49,7 +49,7 @@ public class Door : MonoBehaviour {
locked = false;
boundingBox.enabled = false;
triggerBox.enabled = true;
GetComponent<SpriteRenderer>().enabled = false;
//GetComponent<SpriteRenderer>().enabled = false;
}
/// <summary>

View file

@ -123,22 +123,7 @@ public class DungeonGenerator {
AddCurve(rooms2, ed);
}
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++ ) {
if ( !path.tiles.ContainsKey(new Vector2Int(x2, y2)) )
path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL);
}
}
}
HashSet<Vector2Int> allDoors = new HashSet<Vector2Int>();
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++ ) {
@ -148,6 +133,7 @@ public class DungeonGenerator {
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;
}
allDoors.UnionWith(r.AllDoors());
foreach ( Vector2Int v in r.AllDoors() ) {
Debug.Log("Door: " + v);
if ( !r.bounds.Contains(v) )
@ -155,11 +141,34 @@ public class DungeonGenerator {
else
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 ) {
generateInterior(r);
}
//foreach (GenRoom r in rooms) {
// generateInterior (r);
//}
start = root.r;
end = null; foreach ( GenRoom r in rooms ) {
@ -319,7 +328,8 @@ public class DungeonGenerator {
if ( lower == lefter )
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsRight.Add(new Vector2Int(horizontalLower.bounds.x - 1, horizontalLower.bounds.y + i));
} else
}
else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsLeft.Add(new Vector2Int(horizontalLower.bounds.x + horizontalLower.bounds.width, horizontalLower.bounds.y + i));
}
@ -329,7 +339,8 @@ public class DungeonGenerator {
if ( lower == righter )
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsRight.Add(new Vector2Int(horizontalHigher.bounds.x - 1, horizontalHigher.bounds.y + i));
} else
}
else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsLeft.Add(new Vector2Int(horizontalHigher.bounds.x + horizontalHigher.bounds.width, horizontalHigher.bounds.y + i));
}
@ -339,7 +350,8 @@ public class DungeonGenerator {
if ( lower == lefter )
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1));
} else
}
else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height));
}
@ -349,7 +361,8 @@ public class DungeonGenerator {
if ( lower == righter )
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
lower.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1));
} else
}
else
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height));
}