1
0
Fork 0

Generation Processor Formatting

This commit is contained in:
Triceraptodactyl 2018-04-25 12:42:33 +02:00
parent e5ff478a13
commit d0f44c47b8

View file

@ -6,6 +6,7 @@ public class GenerationProcessor {
public enum ExtendedTileType {
BorderOuter, BorderInner, BorderSingle, Ground0, Ground1, Ground2, Ground3, DoorInner, DoorOuter, Rock, RockL, RockU, RockR, RockD, RockLU, RockLR, RockLD, RockUR, RockUD, RockRD, RockLURD, RockLUD, RockLUR, RockURD, RockLRD, Flag
}
Dictionary<ExtendedTileType, GameObject> prefabs;
public GenerationProcessor(Dictionary<ExtendedTileType, GameObject> prefabs) {
this.prefabs = prefabs;
@ -20,7 +21,7 @@ public class GenerationProcessor {
int rotation = 0;
switch ( tiles[v].type ) {
case Room.TileType.WALL:
type = GetCorrectWallType(tiles, v);
type = GetCorrectRockType(tiles, v);
rotation = GetCorrectWallRotation(tiles, v, type);
break;
case Room.TileType.GROUND:
@ -92,10 +93,7 @@ public class GenerationProcessor {
toCheck = v + new Vector2Int(0, 1);
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
return 180;
toCheck = v + new Vector2Int(1, 0);
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
return 90;
break;
case ExtendedTileType.BorderInner:
toCheck = v + new Vector2Int(1, -1);
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
@ -106,10 +104,7 @@ public class GenerationProcessor {
toCheck = v + new Vector2Int(-1, 1);
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
return 180;
toCheck = v + new Vector2Int(-1, -1);
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
return 270;
break;
case ExtendedTileType.BorderOuter:
Vector2Int toCheck1 = v + new Vector2Int(0, -1);
Vector2Int toCheck2 = v + new Vector2Int(-1, 0);
@ -121,10 +116,7 @@ public class GenerationProcessor {
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;
break;
}
return 0;
}
@ -195,17 +187,13 @@ public class GenerationProcessor {
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
neighbourDoors++;
switch ( neighbourDoors ) {
case 1:
if(neighbourDoors == 1)
return ExtendedTileType.DoorOuter;
default:
return ExtendedTileType.DoorInner;
}
}
private int GetCorrectDoorRotation(ExtendedTileType type, Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
switch ( type ) {
case ExtendedTileType.DoorOuter:
if(type == ExtendedTileType.DoorOuter) {
Vector2Int toCheck = position + new Vector2Int(0, -1);
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
return 270;
@ -215,14 +203,11 @@ public class GenerationProcessor {
toCheck = position + new Vector2Int(0, 1);
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
return 90;
toCheck = position + new Vector2Int(1, 0);
return 0;
case ExtendedTileType.DoorInner:
Vector2Int toCheckD = position + new Vector2Int(0, -1);
if ( tiles.ContainsKey(toCheckD) && tiles[toCheckD].type == Room.TileType.DOOR )
return 90;
return 0;
}
toCheck = position + new Vector2Int(0, -1);
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
return 90;
return 0;
}