1
0
Fork 0

Korrektes darstellen der Ecken der Wände

This commit is contained in:
Triceraptodactyl 2018-04-24 21:27:15 +02:00
parent 47c21f8b82
commit 1714b3af31

View file

@ -21,7 +21,7 @@ public class GenerationProcessor {
switch ( tiles[v].type ) { switch ( tiles[v].type ) {
case Room.TileType.WALL: case Room.TileType.WALL:
type = GetCorrectWallType(tiles, v); type = GetCorrectWallType(tiles, v);
rotation = GetCorrectWallRotation(type, tiles[v].position); rotation = GetCorrectWallRotation(tiles, v, type);
break; break;
case Room.TileType.GROUND: case Room.TileType.GROUND:
type = GetRandomGroundType(); type = GetRandomGroundType();
@ -84,43 +84,53 @@ public class GenerationProcessor {
} }
} }
private int GetCorrectWallRotation(ExtendedTileType type, GenTile.Position position) { private int GetCorrectWallRotation(Dictionary<Vector2Int, GenTile> tiles, Vector2Int v, ExtendedTileType type) {
int rotation = 0;
switch ( type ) { switch ( type ) {
case ExtendedTileType.BorderSingle: case ExtendedTileType.BorderSingle:
switch ( position ) { Vector2Int toCheck = v + new Vector2Int(0, -1);
case GenTile.Position.BOTTOM: if(tiles.ContainsKey(toCheck) && (tiles[toCheck].type == Room.TileType.GROUND || tiles[toCheck].type == Room.TileType.GROUND))
rotation = 180; return 0;
break; toCheck = v + new Vector2Int(-1, 0);
case GenTile.Position.LEFT: if(tiles.ContainsKey(toCheck) && (tiles[toCheck].type == Room.TileType.GROUND || tiles[toCheck].type == Room.TileType.GROUND))
rotation = 90; return 270;
break; toCheck = v + new Vector2Int(0, 1);
case GenTile.Position.TOP: if(tiles.ContainsKey(toCheck) && (tiles[toCheck].type == Room.TileType.GROUND || tiles[toCheck].type == Room.TileType.GROUND))
rotation = 0; return 180;
break; toCheck = v + new Vector2Int(1, 0);
case GenTile.Position.RIGHT: if(tiles.ContainsKey(toCheck) && (tiles[toCheck].type == Room.TileType.GROUND || tiles[toCheck].type == Room.TileType.GROUND))
rotation = 270; return 90;
break;
}
break; break;
case ExtendedTileType.BorderInner: case ExtendedTileType.BorderInner:
switch ( position ) { toCheck = v + new Vector2Int(1, -1);
case GenTile.Position.BOTTOM_LEFT: if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
rotation = 90; return 0;
break; toCheck = v + new Vector2Int(1, 1);
case GenTile.Position.TOP_LEFT: if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
rotation = 0; return 90;
break; toCheck = v + new Vector2Int(-1, 1);
case GenTile.Position.TOP_RIGHT: if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
rotation = 270; return 180;
break; toCheck = v + new Vector2Int(-1, -1);
case GenTile.Position.BOTTOM_RIGHT: if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
rotation = 180; return 270;
break; break;
} case ExtendedTileType.BorderOuter:
Vector2Int toCheck1 = v + new Vector2Int(0, -1);
Vector2Int toCheck2 = v + new Vector2Int(-1, 0);
if(tiles.ContainsKey(toCheck1) && tiles.ContainsKey(toCheck2) && tiles[toCheck1].type == Room.TileType.WALL && tiles[toCheck2].type == Room.TileType.WALL)
return 90;
toCheck1 = v + new Vector2Int(0, 1);
if(tiles.ContainsKey(toCheck1) && tiles.ContainsKey(toCheck2) && tiles[toCheck1].type == Room.TileType.WALL && tiles[toCheck2].type == Room.TileType.WALL)
return 0;
toCheck2 = v + new Vector2Int(1, 0);
if(tiles.ContainsKey(toCheck1) && tiles.ContainsKey(toCheck2) && tiles[toCheck1].type == Room.TileType.WALL && tiles[toCheck2].type == Room.TileType.WALL)
return 270;
toCheck1 = v + new Vector2Int(0, -1);
if(tiles.ContainsKey(toCheck1) && tiles.ContainsKey(toCheck2) && tiles[toCheck1].type == Room.TileType.WALL && tiles[toCheck2].type == Room.TileType.WALL)
return 180;
break; break;
} }
return rotation; return 0;
} }
private ExtendedTileType GetCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) { private ExtendedTileType GetCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {