Add ToOuter to door | PlayerSettings
This commit is contained in:
parent
fb2ba06537
commit
e49d5d2ea4
5 changed files with 232 additions and 214 deletions
|
@ -7,6 +7,8 @@ public class Door : MonoBehaviour {
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
Room parent;
|
Room parent;
|
||||||
|
|
||||||
|
Vector2Int toOuter;
|
||||||
|
|
||||||
BoxCollider2D boundingBox;
|
BoxCollider2D boundingBox;
|
||||||
BoxCollider2D triggerBox;
|
BoxCollider2D triggerBox;
|
||||||
|
|
||||||
|
@ -33,6 +35,10 @@ public class Door : MonoBehaviour {
|
||||||
this.parent = room;
|
this.parent = room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetToOuter(Vector2Int v) {
|
||||||
|
toOuter = v;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Locks the door.
|
/// Locks the door.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -73,12 +79,13 @@ public class Door : MonoBehaviour {
|
||||||
Player player = collision.gameObject.GetComponent<Player>();
|
Player player = collision.gameObject.GetComponent<Player>();
|
||||||
Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
|
Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
|
||||||
Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
|
Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
|
||||||
if (centerToCollider.magnitude - 1 < centerToPlayer.magnitude) {
|
if (centerToCollider.magnitude - 0.89 < centerToPlayer.magnitude) {
|
||||||
Debug.Log(centerToCollider.magnitude - 1);
|
Debug.Log(centerToCollider.magnitude - 0.89);
|
||||||
Debug.Log(centerToPlayer.magnitude);
|
Debug.Log(centerToPlayer.magnitude);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Debug.Log(centerToCollider.magnitude - 0.89);
|
||||||
|
Debug.Log(centerToPlayer.magnitude);
|
||||||
Debug.Log("Leaving Trigger");
|
Debug.Log("Leaving Trigger");
|
||||||
if(parent == null) {
|
if(parent == null) {
|
||||||
Debug.Log("This door has no parent Room!");
|
Debug.Log("This door has no parent Room!");
|
||||||
|
|
|
@ -34,14 +34,18 @@ public class GenerationProcessor {
|
||||||
type = GetCorrectRockType(tiles, v);
|
type = GetCorrectRockType(tiles, v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CreateGOFromType(v, rotation, tiles[v].type, type, root);
|
GameObject go = CreateGOFromType(v, rotation, tiles[v].type, type, root);
|
||||||
|
// Todo dirty hack
|
||||||
|
if ( go.tag == "door" ) {
|
||||||
|
go.GetComponent<Door>().SetToOuter(GenerationProcessor.GetDirectionVector(tiles[v].position));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) {
|
public GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) {
|
||||||
GameObject tmp = null;
|
GameObject tmp = null;
|
||||||
if (type != Room.TileType.GROUND)
|
if ( type != Room.TileType.GROUND )
|
||||||
CreateGOFromType(v, 0, Room.TileType.GROUND, GetRandomGroundType(), root);
|
CreateGOFromType(v, 0, Room.TileType.GROUND, GetRandomGroundType(), root);
|
||||||
if ( prefabs.ContainsKey(t) && root != null ) {
|
if ( prefabs.ContainsKey(t) && root != null ) {
|
||||||
tmp = Object.Instantiate(prefabs[t], root.transform);
|
tmp = Object.Instantiate(prefabs[t], root.transform);
|
||||||
|
@ -54,23 +58,23 @@ public class GenerationProcessor {
|
||||||
private int CountSpecificNeighbours(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position, Room.TileType type) {
|
private int CountSpecificNeighbours(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position, Room.TileType type) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == type)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == type )
|
||||||
counter++;
|
counter++;
|
||||||
toCheck = position + new Vector2Int(-1, 0);
|
toCheck = position + new Vector2Int(-1, 0);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == type)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == type )
|
||||||
counter++;
|
counter++;
|
||||||
toCheck = position + new Vector2Int(0, 1);
|
toCheck = position + new Vector2Int(0, 1);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == type)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == type )
|
||||||
counter++;
|
counter++;
|
||||||
toCheck = position + new Vector2Int(1, 0);
|
toCheck = position + new Vector2Int(1, 0);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == type)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == type )
|
||||||
counter++;
|
counter++;
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExtendedTileType GetCorrectWallType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position){
|
private ExtendedTileType GetCorrectWallType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
int groundNumber = CountSpecificNeighbours(tiles, position, Room.TileType.GROUND) + CountSpecificNeighbours(tiles, position, Room.TileType.ROCK);
|
int groundNumber = CountSpecificNeighbours(tiles, position, Room.TileType.GROUND) + CountSpecificNeighbours(tiles, position, Room.TileType.ROCK);
|
||||||
switch(groundNumber){
|
switch ( groundNumber ) {
|
||||||
case 0:
|
case 0:
|
||||||
return ExtendedTileType.BorderInner;
|
return ExtendedTileType.BorderInner;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -82,9 +86,9 @@ public class GenerationProcessor {
|
||||||
|
|
||||||
private int GetCorrectWallRotation(ExtendedTileType type, GenTile.Position position) {
|
private int GetCorrectWallRotation(ExtendedTileType type, GenTile.Position position) {
|
||||||
int rotation = 0;
|
int rotation = 0;
|
||||||
switch (type) {
|
switch ( type ) {
|
||||||
case ExtendedTileType.BorderSingle:
|
case ExtendedTileType.BorderSingle:
|
||||||
switch (position) {
|
switch ( position ) {
|
||||||
case GenTile.Position.BOTTOM:
|
case GenTile.Position.BOTTOM:
|
||||||
rotation = 180;
|
rotation = 180;
|
||||||
break;
|
break;
|
||||||
|
@ -100,7 +104,7 @@ public class GenerationProcessor {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ExtendedTileType.BorderInner:
|
case ExtendedTileType.BorderInner:
|
||||||
switch (position) {
|
switch ( position ) {
|
||||||
case GenTile.Position.BOTTOM_LEFT:
|
case GenTile.Position.BOTTOM_LEFT:
|
||||||
rotation = 90;
|
rotation = 90;
|
||||||
break;
|
break;
|
||||||
|
@ -122,19 +126,19 @@ public class GenerationProcessor {
|
||||||
private ExtendedTileType GetCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
private ExtendedTileType GetCorrectRockType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
int meta = 0;
|
int meta = 0;
|
||||||
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
Vector2Int toCheck = position + new Vector2Int(0, -1);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK )
|
||||||
meta += 1;
|
meta += 1;
|
||||||
toCheck = position + new Vector2Int(-1, 0);
|
toCheck = position + new Vector2Int(-1, 0);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK )
|
||||||
meta += 2;
|
meta += 2;
|
||||||
toCheck = position + new Vector2Int(0, 1);
|
toCheck = position + new Vector2Int(0, 1);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK )
|
||||||
meta += 4;
|
meta += 4;
|
||||||
toCheck = position + new Vector2Int(1, 0);
|
toCheck = position + new Vector2Int(1, 0);
|
||||||
if (tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK)
|
if ( tiles.ContainsKey(toCheck) && tiles[toCheck].type == Room.TileType.ROCK )
|
||||||
meta += 8;
|
meta += 8;
|
||||||
|
|
||||||
switch(meta) {
|
switch ( meta ) {
|
||||||
case 1:
|
case 1:
|
||||||
return ExtendedTileType.RockD;
|
return ExtendedTileType.RockD;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -172,7 +176,7 @@ public class GenerationProcessor {
|
||||||
|
|
||||||
private ExtendedTileType GetCorrectDoorType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
private ExtendedTileType GetCorrectDoorType(Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
int neighbourDoors = CountSpecificNeighbours(tiles, position, Room.TileType.DOOR);
|
int neighbourDoors = CountSpecificNeighbours(tiles, position, Room.TileType.DOOR);
|
||||||
switch(neighbourDoors) {
|
switch ( neighbourDoors ) {
|
||||||
case 1:
|
case 1:
|
||||||
return ExtendedTileType.DoorOuter;
|
return ExtendedTileType.DoorOuter;
|
||||||
default:
|
default:
|
||||||
|
@ -181,31 +185,46 @@ public class GenerationProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetCorrectDoorRotation(ExtendedTileType type, Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
private int GetCorrectDoorRotation(ExtendedTileType type, Dictionary<Vector2Int, GenTile> tiles, Vector2Int position) {
|
||||||
switch(type) {
|
switch ( type ) {
|
||||||
case ExtendedTileType.DoorOuter:
|
case ExtendedTileType.DoorOuter:
|
||||||
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 )
|
||||||
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;
|
return 90;
|
||||||
toCheck = position + new Vector2Int(1, 0);
|
toCheck = position + new Vector2Int(1, 0);
|
||||||
return 0;
|
return 0;
|
||||||
case ExtendedTileType.DoorInner:
|
case ExtendedTileType.DoorInner:
|
||||||
Vector2Int toCheckD = position + new Vector2Int(0, -1);
|
Vector2Int toCheckD = position + new Vector2Int(0, -1);
|
||||||
if(tiles.ContainsKey(toCheckD) && tiles[toCheckD].type == Room.TileType.DOOR)
|
if ( tiles.ContainsKey(toCheckD) && tiles[toCheckD].type == Room.TileType.DOOR )
|
||||||
return 90;
|
return 90;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector2Int GetDirectionVector(GenTile.Position p) {
|
||||||
|
switch ( p ) {
|
||||||
|
case GenTile.Position.TOP:
|
||||||
|
return new Vector2Int(0, 1);
|
||||||
|
case GenTile.Position.LEFT:
|
||||||
|
return new Vector2Int(-1, 0);
|
||||||
|
case GenTile.Position.RIGHT:
|
||||||
|
return new Vector2Int(1, 0);
|
||||||
|
case GenTile.Position.BOTTOM:
|
||||||
|
return new Vector2Int(0, -1);
|
||||||
|
default:
|
||||||
|
return new Vector2Int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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:
|
||||||
|
|
|
@ -31,14 +31,6 @@ public class StartObjective : Objective {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the created Player object. Call this after <see cref="ActivateGoal(Player)"/> !
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Player</returns>
|
|
||||||
public Player GetPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Code executed if the goal is reached eg. opening doors.
|
/// Code executed if the goal is reached eg. opening doors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -12,8 +12,8 @@ PlayerSettings:
|
||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: Bildschirmflausch
|
||||||
productName: New Unity Project
|
productName: Dungeon Drifter
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||||
|
@ -543,7 +543,7 @@ PlayerSettings:
|
||||||
splashScreenBackgroundSourceLandscape: {fileID: 0}
|
splashScreenBackgroundSourceLandscape: {fileID: 0}
|
||||||
splashScreenBackgroundSourcePortrait: {fileID: 0}
|
splashScreenBackgroundSourcePortrait: {fileID: 0}
|
||||||
spritePackerPolicy:
|
spritePackerPolicy:
|
||||||
webGLMemorySize: 256
|
webGLMemorySize: 512
|
||||||
webGLExceptionSupport: 1
|
webGLExceptionSupport: 1
|
||||||
webGLNameFilesAsHashes: 0
|
webGLNameFilesAsHashes: 0
|
||||||
webGLDataCaching: 0
|
webGLDataCaching: 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue