1
0
Fork 0

Add ToOuter to door | PlayerSettings

This commit is contained in:
Saibotk 2018-04-24 05:49:27 +02:00
parent fb2ba06537
commit e49d5d2ea4
5 changed files with 232 additions and 214 deletions

View file

@ -7,6 +7,8 @@ public class Door : MonoBehaviour {
[SerializeField]
Room parent;
Vector2Int toOuter;
BoxCollider2D boundingBox;
BoxCollider2D triggerBox;
@ -33,6 +35,10 @@ public class Door : MonoBehaviour {
this.parent = room;
}
public void SetToOuter(Vector2Int v) {
toOuter = v;
}
/// <summary>
/// Locks the door.
/// </summary>
@ -73,12 +79,13 @@ public class Door : MonoBehaviour {
Player player = collision.gameObject.GetComponent<Player>();
Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetPosition() + parent.GetCenter();
if (centerToCollider.magnitude - 1 < centerToPlayer.magnitude) {
Debug.Log(centerToCollider.magnitude - 1);
if (centerToCollider.magnitude - 0.89 < centerToPlayer.magnitude) {
Debug.Log(centerToCollider.magnitude - 0.89);
Debug.Log(centerToPlayer.magnitude);
return;
}
Debug.Log(centerToCollider.magnitude - 0.89);
Debug.Log(centerToPlayer.magnitude);
Debug.Log("Leaving Trigger");
if(parent == null) {
Debug.Log("This door has no parent Room!");

View file

@ -34,7 +34,11 @@ public class GenerationProcessor {
type = GetCorrectRockType(tiles, v);
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;
}
@ -203,6 +207,21 @@ public class GenerationProcessor {
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() {
int num = ( int ) ( UnityEngine.Random.value * 4 );
switch ( num ) {

View file

@ -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>
/// Code executed if the goal is reached eg. opening doors.
/// </summary>

View file

@ -12,8 +12,8 @@ PlayerSettings:
targetDevice: 2
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: DefaultCompany
productName: New Unity Project
companyName: Bildschirmflausch
productName: Dungeon Drifter
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@ -543,7 +543,7 @@ PlayerSettings:
splashScreenBackgroundSourceLandscape: {fileID: 0}
splashScreenBackgroundSourcePortrait: {fileID: 0}
spritePackerPolicy:
webGLMemorySize: 256
webGLMemorySize: 512
webGLExceptionSupport: 1
webGLNameFilesAsHashes: 0
webGLDataCaching: 0