From 247458896057d9d073004417977d56a87c0629e1 Mon Sep 17 00:00:00 2001 From: Robin Ruud Kristensen <robin1998@hotmail.no> Date: Thu, 10 Nov 2022 20:06:17 +0100 Subject: [PATCH] check for room and enemies --- MrBigsock/Assets/Code/InteractionSystem/Door.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MrBigsock/Assets/Code/InteractionSystem/Door.cs b/MrBigsock/Assets/Code/InteractionSystem/Door.cs index caa1b80e..d90a8a7f 100644 --- a/MrBigsock/Assets/Code/InteractionSystem/Door.cs +++ b/MrBigsock/Assets/Code/InteractionSystem/Door.cs @@ -11,14 +11,15 @@ namespace BigSock.Interact { public Sprite newSprite; private GameObject[] enemies; private GameObject player; - private GameObject cameraPlayer; - private int i = TilemapGenerator.NextRoom(); - private GameObject boundary; + private GameObject cameraPlayer; + private int i = TilemapGenerator.NextRoom(); + private GameObject boundary; - public string InteractionPrompt => _prompt; + public string InteractionPrompt => _prompt; - public bool Interact(Interactor interactor) { - enemies = GameObject.FindGameObjectsWithTag((i - 1).ToString()); + public bool Interact(Interactor interactor) { + if(i > 0)enemies = GameObject.FindGameObjectsWithTag((i - 1).ToString()); + else if (i > 0) enemies = GameObject.FindGameObjectsWithTag((0).ToString()); if (enemies.Length == 0) { Debug.Log("Opening door!"); -- GitLab