diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index ef5663e..b403079 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -10,7 +10,7 @@ public class Door : MonoBehaviour { BoxCollider2D triggerBox; // Use this for initialization - void Start() { + void Awake() { BoxCollider2D[] colliders = GetComponents(); foreach ( BoxCollider2D collider in colliders ) { if ( collider.isTrigger ) { @@ -21,7 +21,6 @@ public class Door : MonoBehaviour { //Debug.Log("Found Door collider"); } } - Unlock(); } /// diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 10bad27..87ad28b 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -176,7 +176,7 @@ public class GameController : MonoBehaviour { spawnpointRoot.transform.position = new Vector3(dg.start.roomPosition.x, dg.start.roomPosition.y, 0); GameObject spawn = new GameObject(); spawn.transform.SetParent(spawnpointRoot.transform); - spawn.transform.position = new Vector3(3, 3, 0); + spawn.transform.position = new Vector3(dg.start.GetCenter().x, dg.start.GetCenter().y, 0); start.SetSpawnPointsRootObject(spawnpointRoot); start.Reload(); diff --git a/Assets/Scripts/Objectives/EntityObjective.cs b/Assets/Scripts/Objectives/EntityObjective.cs index fe6f2fd..68603ad 100644 --- a/Assets/Scripts/Objectives/EntityObjective.cs +++ b/Assets/Scripts/Objectives/EntityObjective.cs @@ -24,6 +24,9 @@ public class EntityObjective : Objective { /// /// Player public override void ActivateGoal(Player ply) { + if ( activated ) + return; + activated = true; base.ActivateGoal(ply); foreach ( GameObject i in prefabList ) { Debug.Log("[ROOMS] Spawning Entity..."); diff --git a/Assets/Scripts/Objectives/Objective.cs b/Assets/Scripts/Objectives/Objective.cs index e47dca2..75ceaa5 100644 --- a/Assets/Scripts/Objectives/Objective.cs +++ b/Assets/Scripts/Objectives/Objective.cs @@ -1,8 +1,10 @@ -public abstract class Objective { +using UnityEngine; + +public abstract class Objective { protected Room room; protected Player player; - bool activated; - bool finished; + protected bool activated; + protected bool finished; /// /// Constructs a new Objective instance. @@ -34,6 +36,7 @@ protected virtual void ReachedGoal() { finished = true; room.Unlock(); + Debug.Log("[ROOM] Goal reached. Doors will open."); } /// diff --git a/Assets/Scripts/Objectives/StartObjective.cs b/Assets/Scripts/Objectives/StartObjective.cs index e7678b1..26e0375 100644 --- a/Assets/Scripts/Objectives/StartObjective.cs +++ b/Assets/Scripts/Objectives/StartObjective.cs @@ -20,11 +20,14 @@ public class StartObjective : Objective { /// /// Player is ignored public override void ActivateGoal(Player player) { + if ( activated ) + return; if ( room.GetSpawnpoints().Count > 0 ) { GameObject ply = GameObject.Instantiate(playerPrefab); ply.transform.position = room.GetSpawnpoints()[0].position; player = ply.GetComponent(); base.ActivateGoal(player); + UpdateGoal(); } } diff --git a/Assets/Scripts/Room.cs b/Assets/Scripts/Room.cs index 0e30625..2e28e84 100644 --- a/Assets/Scripts/Room.cs +++ b/Assets/Scripts/Room.cs @@ -20,7 +20,7 @@ public class Room : MonoBehaviour { private Objective objective; // Use this for initialization - void Start() { + void Awake() { doors = new List(); if ( doorsRootObject != null ) { foreach ( Door d in doorsRootObject.GetComponentsInChildren() ) { @@ -38,7 +38,7 @@ public class Room : MonoBehaviour { } //Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count); } - //Unlock(); + Unlock(); } /// @@ -62,6 +62,7 @@ public class Room : MonoBehaviour { } //Debug.Log("[ROOMS] Spawnpoints: " + spawnpoints.Count); } + Unlock(); // Ok to do so? } ///