1
0
Fork 0

update door logic

This commit is contained in:
Saibotk 2018-04-24 07:21:56 +02:00
parent 5dcc925067
commit f658322d48
2 changed files with 7 additions and 4 deletions

View file

@ -71,6 +71,8 @@ public class Door : MonoBehaviour {
private void Update() {
Debug.DrawLine(gameObject.transform.position, gameObject.transform.position + new Vector3(toOuter.x, toOuter.y, 0));
Debug.DrawLine(new Vector3(), ( Vector2 ) ( parent.GetCenter() ));
Debug.DrawLine((Vector2)parent.GetCenter(), ( gameObject.transform.position ));
}
/// <summary>
@ -81,14 +83,15 @@ public class Door : MonoBehaviour {
// TODO only works correct for entering a room!
if ( collision.tag == "Player") {
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();
Vector2 centerToCollider = (Vector2) gameObject.transform.position - parent.GetCenter();
Vector2 centerToPlayer = (Vector2) player.gameObject.transform.position - parent.GetCenter();
float angle = Vector2.Angle(toOuter, ( centerToPlayer - centerToCollider ));
if ( (angle > 90 && angle < 270) ) {
if ( (angle > 90 && angle < 270) && (centerToPlayer - centerToCollider).magnitude < 1) {
Debug.Log("Player is on the outside! Angle: " + angle);
return;
}
Debug.Log("magn: " + ( centerToPlayer - centerToCollider ).magnitude);
Debug.Log("Leaving Trigger");
if(parent == null) {
Debug.Log("This door has no parent Room!");

View file

@ -453,7 +453,7 @@ public class DungeonGenerator {
}
}
}
Debug.Log(r.GetCenter() + " " + r.spawnpoints.Count + " spawn points.");
//Debug.Log(r.GetCenter() + " " + r.spawnpoints.Count + " spawn points.");
}
public static void GenerateObjective(Room r) {