Should have fixed doors
But they are still broken
This commit is contained in:
parent
5a01e45f0c
commit
7029f346e3
4 changed files with 68 additions and 15 deletions
|
@ -169,7 +169,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 2cf81aa4a8d45468f8184f8d5862d7eb, type: 3}
|
m_Script: {fileID: 11500000, guid: 2cf81aa4a8d45468f8184f8d5862d7eb, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
acceleration: 3
|
acceleration: 4
|
||||||
friction: 0.1
|
friction: 0.1
|
||||||
turnSpeed: 2
|
turnSpeed: 2
|
||||||
drift: 1
|
drift: 1
|
||||||
|
|
|
@ -986,6 +986,48 @@ CanvasRenderer:
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 833134303}
|
m_GameObject: {fileID: 833134303}
|
||||||
|
--- !u!1001 &865504979
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4079161515917916, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 4
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 100100000, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2}
|
||||||
|
m_IsPrefabParent: 0
|
||||||
--- !u!1 &881384367
|
--- !u!1 &881384367
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1079,7 +1121,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3}
|
m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
followThis: {fileID: 0}
|
followThis: {fileID: 1239288696}
|
||||||
--- !u!1 &1001682580
|
--- !u!1 &1001682580
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1328,7 +1370,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &1487324257
|
--- !u!114 &1487324257
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class DungeonGenerator {
|
||||||
foreach ( GenVertex r1 in Q ) {
|
foreach ( GenVertex r1 in Q ) {
|
||||||
foreach ( GenVertex r2 in Q ) {
|
foreach ( GenVertex r2 in Q ) {
|
||||||
if ( r1 == r2 )
|
if ( r1 == r2 )
|
||||||
continue;
|
goto outer;
|
||||||
foreach ( GenEdge e in E )
|
foreach ( GenEdge e in E )
|
||||||
if ( e.r2 == r1 && e.r1 == r2 )
|
if ( e.r2 == r1 && e.r1 == r2 )
|
||||||
goto outer;
|
goto outer;
|
||||||
|
@ -134,30 +134,34 @@ public class DungeonGenerator {
|
||||||
path.tiles.Add(pos1, Room.TileType.GROUND);
|
path.tiles.Add(pos1, Room.TileType.GROUND);
|
||||||
for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ )
|
for ( int x2 = x1 - 1; x2 <= x1 + 1; x2++ )
|
||||||
for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) {
|
for ( int y2 = y1 - 1; y2 <= y1 + 1; y2++ ) {
|
||||||
if ( !path.tiles.ContainsKey(new Vector2Int(x2, y2)) )
|
if (!path.tiles.ContainsKey(new Vector2Int(x2, y2)))
|
||||||
path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL);
|
path.tiles.Add(new Vector2Int(x2, y2), Room.TileType.WALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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++ ) {
|
||||||
r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL);
|
r.tiles.Add(new Vector2Int(x1, y1), Room.TileType.WALL);
|
||||||
}
|
}
|
||||||
for ( int x1 = r.bounds.x + 1; x1 < r.bounds.x + r.bounds.width - 1; x1++ )
|
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++ ) {
|
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;
|
||||||
}
|
}
|
||||||
foreach ( Vector2Int v in r.AllDoors() )
|
foreach (Vector2Int v in r.AllDoors())
|
||||||
r.tiles[v] = Room.TileType.DOOR;
|
{
|
||||||
|
Debug.Log("Door: " + v);
|
||||||
|
if (!r.bounds.Contains(v))
|
||||||
|
throw new NotSupportedException("This is a bug where doors land in the wrong room. It should have been fixed.");
|
||||||
|
else
|
||||||
|
r.tiles[v] = Room.TileType.DOOR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (GenRoom r in rooms) {
|
foreach (GenRoom r in rooms) {
|
||||||
generateInterior (r);
|
generateInterior (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
rooms.Add(path);
|
|
||||||
|
|
||||||
start = root.r;
|
start = root.r;
|
||||||
end = null; foreach ( GenRoom r in rooms ) {
|
end = null; foreach ( GenRoom r in rooms ) {
|
||||||
if ( end == null || r.bounds.x > end.bounds.x )
|
if ( end == null || r.bounds.x > end.bounds.x )
|
||||||
|
@ -218,8 +222,8 @@ public class DungeonGenerator {
|
||||||
rooms.Add(tunnel);
|
rooms.Add(tunnel);
|
||||||
|
|
||||||
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
||||||
lower.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height));
|
higher.doorsUp.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y + tunnel.bounds.height));
|
||||||
higher.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1));
|
lower.doorsDown.Add(new Vector2Int(tunnel.bounds.x + i, tunnel.bounds.y - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,14 +342,14 @@ public class DungeonGenerator {
|
||||||
lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1));
|
lower.doorsDown.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y - 1));
|
||||||
} else
|
} else
|
||||||
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
||||||
lower.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height));
|
higher.doorsUp.Add(new Vector2Int(verticalLefter.bounds.x + i, verticalLefter.bounds.y + verticalLefter.bounds.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( addVertical2 ) {
|
if ( addVertical2 ) {
|
||||||
rooms.Add(verticalRighter);
|
rooms.Add(verticalRighter);
|
||||||
if ( lower == righter )
|
if ( lower == righter )
|
||||||
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
||||||
higher.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1));
|
lower.doorsDown.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y - 1));
|
||||||
} else
|
} else
|
||||||
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
for ( int i = 0; i < TUNNEL_THICKNESS; i++ ) {
|
||||||
higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height));
|
higher.doorsUp.Add(new Vector2Int(verticalRighter.bounds.x + i, verticalRighter.bounds.y + verticalRighter.bounds.height));
|
||||||
|
|
|
@ -21,6 +21,13 @@ public class GenRoom {
|
||||||
|
|
||||||
public float Distance(GenRoom r) {
|
public float Distance(GenRoom r) {
|
||||||
return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y);
|
return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y);
|
||||||
|
//float power = 2;
|
||||||
|
//float dist = (float) Math.Pow(
|
||||||
|
// Math.Pow(GetCenter().x - r.GetCenter().x, power)
|
||||||
|
// + Math.Pow(GetCenter().y - r.GetCenter().y, power),
|
||||||
|
// 1 / power);
|
||||||
|
//Debug.Log(bounds.center + " " + bounds + " " + dist);
|
||||||
|
//return dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2Int GetCenter() {
|
public Vector2Int GetCenter() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue