Merge branch 'TriceraptodactylDev'
This commit is contained in:
commit
fb03f163db
3 changed files with 215 additions and 229 deletions
|
@ -6,6 +6,7 @@ public class GenerationProcessor {
|
||||||
public enum ExtendedTileType {
|
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
|
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;
|
Dictionary<ExtendedTileType, GameObject> prefabs;
|
||||||
public GenerationProcessor(Dictionary<ExtendedTileType, GameObject> prefabs) {
|
public GenerationProcessor(Dictionary<ExtendedTileType, GameObject> prefabs) {
|
||||||
this.prefabs = prefabs;
|
this.prefabs = prefabs;
|
||||||
|
@ -92,10 +93,7 @@ public class GenerationProcessor {
|
||||||
toCheck = v + new Vector2Int(0, 1);
|
toCheck = v + new Vector2Int(0, 1);
|
||||||
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
||||||
return 180;
|
return 180;
|
||||||
toCheck = v + new Vector2Int(1, 0);
|
|
||||||
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
|
||||||
return 90;
|
return 90;
|
||||||
break;
|
|
||||||
case ExtendedTileType.BorderInner:
|
case ExtendedTileType.BorderInner:
|
||||||
toCheck = v + new Vector2Int(1, -1);
|
toCheck = v + new Vector2Int(1, -1);
|
||||||
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
||||||
|
@ -106,10 +104,7 @@ public class GenerationProcessor {
|
||||||
toCheck = v + new Vector2Int(-1, 1);
|
toCheck = v + new Vector2Int(-1, 1);
|
||||||
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
||||||
return 180;
|
return 180;
|
||||||
toCheck = v + new Vector2Int(-1, -1);
|
|
||||||
if(tiles.ContainsKey(toCheck) && tiles[toCheck].type != Room.TileType.WALL)
|
|
||||||
return 270;
|
return 270;
|
||||||
break;
|
|
||||||
case ExtendedTileType.BorderOuter:
|
case ExtendedTileType.BorderOuter:
|
||||||
Vector2Int toCheck1 = v + new Vector2Int(0, -1);
|
Vector2Int toCheck1 = v + new Vector2Int(0, -1);
|
||||||
Vector2Int toCheck2 = v + new Vector2Int(-1, 0);
|
Vector2Int toCheck2 = v + new Vector2Int(-1, 0);
|
||||||
|
@ -121,10 +116,7 @@ public class GenerationProcessor {
|
||||||
toCheck2 = v + new Vector2Int(1, 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)
|
if(tiles.ContainsKey(toCheck1) && tiles.ContainsKey(toCheck2) && tiles[toCheck1].type != Room.TileType.WALL && tiles[toCheck2].type != Room.TileType.WALL)
|
||||||
return 90;
|
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;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -183,51 +175,45 @@ public class GenerationProcessor {
|
||||||
private ExtendedTileType GetCorrectDoorType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
private ExtendedTileType GetCorrectDoorType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
int neighbourDoors = 0;
|
int neighbourDoors = 0;
|
||||||
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
neighbourDoors++;
|
neighbourDoors++;
|
||||||
toCheck = position + new Vector2Int(-1, 0);
|
toCheck = position + new Vector2Int(-1, 0);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
neighbourDoors++;
|
neighbourDoors++;
|
||||||
toCheck = position + new Vector2Int(0, 1);
|
toCheck = position + new Vector2Int(0, 1);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
neighbourDoors++;
|
neighbourDoors++;
|
||||||
toCheck = position + new Vector2Int(1, 0);
|
toCheck = position + new Vector2Int(1, 0);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
neighbourDoors++;
|
neighbourDoors++;
|
||||||
|
|
||||||
switch ( neighbourDoors ) {
|
if(neighbourDoors == 1)
|
||||||
case 1:
|
|
||||||
return ExtendedTileType.DoorOuter;
|
return ExtendedTileType.DoorOuter;
|
||||||
default:
|
|
||||||
return ExtendedTileType.DoorInner;
|
return ExtendedTileType.DoorInner;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private int GetCorrectDoorRotation(ExtendedTileType type, Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
private int GetCorrectDoorRotation(ExtendedTileType type, Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
switch ( type ) {
|
Vector2Int toCheck;
|
||||||
case ExtendedTileType.DoorOuter:
|
if(type == ExtendedTileType.DoorOuter) {
|
||||||
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
toCheck = position + new Vector2Int(0, -1);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
return 270;
|
return 270;
|
||||||
toCheck = position + new Vector2Int(-1, 0);
|
toCheck = position + new Vector2Int(-1, 0);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
return 180;
|
return 180;
|
||||||
toCheck = position + new Vector2Int(0, 1);
|
toCheck = position + new Vector2Int(0, 1);
|
||||||
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR )
|
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 90;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
toCheck = position + new Vector2Int(0, -1);
|
||||||
|
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.DOOR)
|
||||||
|
return 90;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2Int GetDirectionVector(GenTile.Position p) {
|
public static Vector2Int GetDirectionVector(GenTile.Position p) {
|
||||||
switch ( p ) {
|
switch(p) {
|
||||||
case GenTile.Position.TOP:
|
case GenTile.Position.TOP:
|
||||||
return new Vector2Int(0, 1);
|
return new Vector2Int(0, 1);
|
||||||
case GenTile.Position.LEFT:
|
case GenTile.Position.LEFT:
|
||||||
|
@ -242,8 +228,8 @@ public class GenerationProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExtendedTileType GetRandomGroundType() {
|
private ExtendedTileType GetRandomGroundType() {
|
||||||
int num = ( int ) ( UnityEngine.Random.value * 4 );
|
int num = (int) (UnityEngine.Random.value * 4);
|
||||||
switch ( num ) {
|
switch(num) {
|
||||||
case 0:
|
case 0:
|
||||||
return ExtendedTileType.Ground0;
|
return ExtendedTileType.Ground0;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 33 KiB |
Loading…
Add table
Reference in a new issue