1
0
Fork 0

Closing rooms works now

This commit is contained in:
Piegames 2018-04-23 17:21:41 +02:00
parent 3bf38b81e1
commit dbc713b6c4
4 changed files with 26 additions and 5 deletions

View file

@ -30,7 +30,7 @@ public class Door : MonoBehaviour {
public void SetParent(Room room) {
this.parent = room;
}
/// <summary>
/// Locks the door.
/// </summary>
@ -65,13 +65,15 @@ public class Door : MonoBehaviour {
/// <param name="collision"></param>
private void OnTriggerExit2D(Collider2D collision) {
if ( collision.tag == "Player") {
// TODO better checks
Player player = collision.gameObject.GetComponent<Player>();
if ((boundingBox.offset - parent.GetCenter()).sqrMagnitude < ((Vector2) player.transform.position - parent.GetCenter()).sqrMagnitude)
return;
Debug.Log("Leaving Trigger");
if(parent == null) {
Debug.Log("This door has no parent Room!");
return;
}
parent.OnPlayerEnter(collision.gameObject.GetComponent<Player>());
parent.OnPlayerEnter(player);
}
}
}

View file

@ -122,8 +122,11 @@ public class GameController : MonoBehaviour {
{ GenerationProcessor.ExtendedTileType.RockLUD, RockLUD },
{ GenerationProcessor.ExtendedTileType.RockLUR, RockLUR },
{ GenerationProcessor.ExtendedTileType.RockURD, RockURD },
{ GenerationProcessor.ExtendedTileType.RockLRD, RockLRD },
{ GenerationProcessor.ExtendedTileType.Ground, Ground },
{ GenerationProcessor.ExtendedTileType.RockLRD, RockLRD },
{ GenerationProcessor.ExtendedTileType.Ground0, Ground0 },
{ GenerationProcessor.ExtendedTileType.Ground1, Ground1 },
{ GenerationProcessor.ExtendedTileType.Ground2, Ground2 },
{ GenerationProcessor.ExtendedTileType.Ground3, Ground3 },
{ GenerationProcessor.ExtendedTileType.DoorInner, DoorInner },
{ GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter }
};

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ec323b9157704d00a3409f8ea6e46b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df6e7833427b5497b92308fb6f54e552
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: