diff --git a/Assets/Scripts/Generation/DungeonGenerator.cs b/Assets/Scripts/Generation/DungeonGenerator.cs index 88d7f99..28a67fa 100644 --- a/Assets/Scripts/Generation/DungeonGenerator.cs +++ b/Assets/Scripts/Generation/DungeonGenerator.cs @@ -127,11 +127,11 @@ 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), Room.TileType.WALL); + r.tiles.Add(new Vector2Int(x1, y1), new GenTile(Room.TileType.WALL)); } 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++ ) { - r.tiles[new Vector2Int(x1, y1)] = Room.TileType.GROUND; + r.tiles[new Vector2Int(x1, y1)].type = Room.TileType.GROUND; } allDoors.UnionWith(r.AllDoors()); foreach ( Vector2Int v in r.AllDoors() ) { @@ -139,7 +139,7 @@ public class DungeonGenerator { 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; + r.tiles[v].type = Room.TileType.DOOR; } } @@ -151,15 +151,15 @@ public class DungeonGenerator { { Vector2Int pos1 = new Vector2Int(x1, y1); if (path.tiles.ContainsKey(pos1)) - path.tiles[pos1] = Room.TileType.GROUND; + path.tiles[pos1].type = Room.TileType.GROUND; else - path.tiles.Add(pos1, Room.TileType.GROUND); + 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, Room.TileType.WALL); + path.tiles.Add(pos2, new GenTile(Room.TileType.WALL)); } } if (r.AllDoors().Count > 0) diff --git a/Assets/Scripts/Generation/GenRoom.cs b/Assets/Scripts/Generation/GenRoom.cs index 2b9fa56..def7eba 100644 --- a/Assets/Scripts/Generation/GenRoom.cs +++ b/Assets/Scripts/Generation/GenRoom.cs @@ -17,7 +17,7 @@ public class GenRoom { // The position of the anchor of the room in world space. This should be the top left corner of the room, but may be any point in the world. public Vector2Int roomPosition; // All positions are in room space relative to the room's anchor - public Dictionary tiles = new Dictionary(); + public Dictionary tiles = new Dictionary(); public float Distance(GenRoom r) { return Math.Abs(GetCenter().x - r.GetCenter().x) + Math.Abs(GetCenter().y - r.GetCenter().y); diff --git a/Assets/Scripts/Generation/GenTile.cs b/Assets/Scripts/Generation/GenTile.cs new file mode 100644 index 0000000..e8a2ae9 --- /dev/null +++ b/Assets/Scripts/Generation/GenTile.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GenTile +{ + public enum Position + { + TOP, BOTTOM, LEFT, RIGHT, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT + } + public Room.TileType type; + public Position position; + + public GenTile() + { + + } + + public GenTile(Room.TileType type) { + this.type = type; + } +} diff --git a/Assets/Scripts/Generation/GenTile.cs.meta b/Assets/Scripts/Generation/GenTile.cs.meta new file mode 100644 index 0000000..63c77e7 --- /dev/null +++ b/Assets/Scripts/Generation/GenTile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b8dce5bdb3204011a32ee1b512a4296 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Generation/GenerationProcessor.cs b/Assets/Scripts/Generation/GenerationProcessor.cs index ee5854c..d2133d3 100644 --- a/Assets/Scripts/Generation/GenerationProcessor.cs +++ b/Assets/Scripts/Generation/GenerationProcessor.cs @@ -11,7 +11,7 @@ public class GenerationProcessor { this.prefabs = prefabs; } - public GameObject ProcessRoom(Dictionary tiles) { + public GameObject ProcessRoom(Dictionary tiles) { GameObject root = new GameObject { name = "Room" }; @@ -56,7 +56,7 @@ public class GenerationProcessor { // // ^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~^~!~ // --------------------------------------------------------------------------------------------------------------------------------------------- - switch ( tiles[v] ) { + switch ( tiles[v].type ) { case Room.TileType.WALL: type = ExtendedTileType.BorderSingle; if ( top && left && tiles.ContainsKey(v + new Vector2Int(-1, -1)) @@ -66,7 +66,9 @@ public class GenerationProcessor { type = ExtendedTileType.BorderOuter; } else if ( top && left || top && right || right && bottom || left && bottom ) { type = ExtendedTileType.BorderInner; - } + } else { + // BorderSingle + } break; case Room.TileType.GROUND: type = ExtendedTileType.Ground;