diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 7474892..e768f4d 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -208,8 +208,8 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 6cab053583d7b91469a214e0bb8c0da0, type: 3} + m_SortingOrder: 2 + m_Sprite: {fileID: 21300000, guid: 147285ed12283414080da771867387c3, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 diff --git a/Assets/Prefabs/StartingRoom.prefab b/Assets/Prefabs/StartingRoom.prefab index bc6a9d0..4276024 100644 --- a/Assets/Prefabs/StartingRoom.prefab +++ b/Assets/Prefabs/StartingRoom.prefab @@ -139,7 +139,7 @@ GameObject: - component: {fileID: 212157662384668488} - component: {fileID: 61742184318168344} m_Layer: 0 - m_Name: Wall + m_Name: Wall (4) m_TagString: wall m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -206,6 +206,23 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1691542046289400 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4993135491924854} + - component: {fileID: 212797466911108054} + - component: {fileID: 61203284340070018} + m_Layer: 0 + m_Name: Wall + m_TagString: wall + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1844252952274974 GameObject: m_ObjectHideFlags: 0 @@ -271,10 +288,10 @@ Transform: m_GameObject: {fileID: 1376851329299758} m_LocalRotation: {x: -0, y: -0, z: 0.7071068, w: 0.7071068} m_LocalPosition: {x: -0.87, y: 9.56, z: 0} - m_LocalScale: {x: 0.1, y: 3, z: 1} + m_LocalScale: {x: 0.10000005, y: 3.000002, z: 1} m_Children: [] m_Father: {fileID: 4896145802546722} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4524829645232432 Transform: @@ -314,7 +331,7 @@ Transform: m_GameObject: {fileID: 1686504243753214} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.3, y: 0.05, z: 1} + m_LocalScale: {x: 20, y: 6, z: 1} m_Children: [] m_Father: {fileID: 4896748037289080} m_RootOrder: 0 @@ -342,6 +359,7 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: + - {fileID: 4993135491924854} - {fileID: 4443867424783896} - {fileID: 4947857444302422} - {fileID: 4958236485783856} @@ -374,7 +392,7 @@ Transform: m_LocalScale: {x: 0.10000005, y: 3, z: 1} m_Children: [] m_Father: {fileID: 4896145802546722} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4947857444302422 Transform: @@ -387,7 +405,7 @@ Transform: m_LocalScale: {x: 0.1, y: 3, z: 1} m_Children: [] m_Father: {fileID: 4896145802546722} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4958236485783856 Transform: @@ -400,8 +418,21 @@ Transform: m_LocalScale: {x: 0.1, y: 3, z: 1} m_Children: [] m_Father: {fileID: 4896145802546722} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} +--- !u!4 &4993135491924854 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1691542046289400} + m_LocalRotation: {x: -0, y: -0, z: 0.7071068, w: 0.7071068} + m_LocalPosition: {x: -0.87, y: 9.56, z: 0} + m_LocalScale: {x: 0.1, y: 3, z: 1} + m_Children: [] + m_Father: {fileID: 4896145802546722} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!61 &61017911347839236 BoxCollider2D: m_ObjectHideFlags: 1 @@ -452,6 +483,31 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 10, y: 10} m_EdgeRadius: 0 +--- !u!61 &61203284340070018 +BoxCollider2D: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1691542046289400} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 2.5762396} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 10, y: 10} + newSize: {x: 10, y: 10} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 10, y: 4.847521} + m_EdgeRadius: 0 --- !u!61 &61328448285356816 BoxCollider2D: m_ObjectHideFlags: 1 @@ -491,11 +547,11 @@ BoxCollider2D: m_UsedByComposite: 0 m_Offset: {x: 0, y: 0} m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0, y: 0} - oldSize: {x: 0, y: 0} - newSize: {x: 0, y: 0} - adaptiveTilingThreshold: 0 + border: {x: 0.049999997, y: 0.049999997, z: 0.049999997, w: 0.049999997} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 0.16, y: 0.16} + newSize: {x: 0.16, y: 0.16} + adaptiveTilingThreshold: 0.5 drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 1 @@ -514,7 +570,7 @@ BoxCollider2D: m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} + m_Offset: {x: 0, y: -2.8089824} m_SpriteTilingProperty: border: {x: 0, y: 0, z: 0, w: 0} pivot: {x: 0.5, y: 0.5} @@ -525,7 +581,7 @@ BoxCollider2D: adaptiveTiling: 0 m_AutoTiling: 0 serializedVersion: 2 - m_Size: {x: 10, y: 10} + m_Size: {x: 10, y: 4.3820353} m_EdgeRadius: 0 --- !u!61 &61881867638551418 BoxCollider2D: @@ -541,11 +597,11 @@ BoxCollider2D: m_UsedByComposite: 0 m_Offset: {x: 0, y: 0} m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0, y: 0} - oldSize: {x: 0, y: 0} - newSize: {x: 0, y: 0} - adaptiveTilingThreshold: 0 + border: {x: 0.049999997, y: 0.049999997, z: 0.049999997, w: 0.049999997} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 0.16, y: 0.16} + newSize: {x: 0.16, y: 0.16} + adaptiveTilingThreshold: 0.5 drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 0 @@ -588,6 +644,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8b8cc30ac6e59724bba6536a17fbf027, type: 3} m_Name: m_EditorClassIdentifier: + graphics: {fileID: 1686504243753214} --- !u!114 &114795477922050694 MonoBehaviour: m_ObjectHideFlags: 1 @@ -772,16 +829,16 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: c4ac414a6adb1234a978da09806b7d81, type: 3} + m_SortingOrder: 1 + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 m_DrawMode: 0 - m_Size: {x: 10, y: 10} + m_Size: {x: 0.16, y: 0.16} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 - m_WasSpriteAssigned: 0 + m_WasSpriteAssigned: 1 m_MaskInteraction: 0 --- !u!212 &212625439943302556 SpriteRenderer: @@ -828,6 +885,51 @@ SpriteRenderer: m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 m_MaskInteraction: 0 +--- !u!212 &212797466911108054 +SpriteRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1691542046289400} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 7cf5bb3a2568ab643b2892aa322e64b2, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 10, y: 10} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 --- !u!212 &212881422167649272 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index 6832cd5..3251d5d 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -803,6 +803,7 @@ GameObject: - component: {fileID: 881384370} - component: {fileID: 881384369} - component: {fileID: 881384368} + - component: {fileID: 881384372} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -844,7 +845,7 @@ Camera: far clip plane: 1000 field of view: 60 orthographic: 1 - orthographic size: 5 + orthographic size: 10 m_Depth: -1 m_CullingMask: serializedVersion: 2 @@ -873,6 +874,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &881384372 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 881384367} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5d9a051e822e2cf4ea3ca01c5a4df37c, type: 3} + m_Name: + m_EditorClassIdentifier: + followThis: {fileID: 0} --- !u!1 &1487324256 GameObject: m_ObjectHideFlags: 0 @@ -900,7 +913,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4f52f2b666c1ec64195aad9936df2d4f, type: 3} m_Name: m_EditorClassIdentifier: - gameOverPanel: {fileID: 216517958} + gameOverPanel: {fileID: 354516592} --- !u!4 &1487324258 Transform: m_ObjectHideFlags: 0 @@ -1021,4 +1034,5 @@ MonoBehaviour: playerPrefab: {fileID: 1679161327080020, guid: 3d1911457c1e44f53b6b4044334db52f, type: 2} start: {fileID: 766094370} - ui: {fileID: 0} + ui: {fileID: 1487324256} + cam: {fileID: 881384367} diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 6b05628..b9f9ff0 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -5,21 +5,31 @@ using UnityEngine; public class CameraControl : MonoBehaviour { [SerializeField] - public GameObject followThis; + private GameObject followThis; private Vector3 offset; void Start() { - offset = transform.position - followThis.transform.position; + if (followThis == null) + return; + offset = transform.position - followThis.transform.position; } void LateUpdate() { + if (followThis == null) + return; var target = followThis.transform.position + offset; var targetVec = target - transform.position; targetVec.Scale (new Vector3 (0.05f, 0.05f, 0)); transform.position = transform.position + targetVec; } + + public void SetFollow(GameObject g) + { + followThis = g; + offset = transform.position - followThis.transform.position; + } } \ No newline at end of file diff --git a/Assets/Scripts/Door.cs b/Assets/Scripts/Door.cs index 5d29729..083a153 100644 --- a/Assets/Scripts/Door.cs +++ b/Assets/Scripts/Door.cs @@ -5,6 +5,9 @@ using UnityEngine; public class Door : MonoBehaviour { private bool locked = false; + [SerializeField] + GameObject graphics; + BoxCollider2D boundingBox; BoxCollider2D triggerBox; // Use this for initialization @@ -13,8 +16,10 @@ public class Door : MonoBehaviour { foreach (BoxCollider2D collider in colliders) { if (collider.isTrigger) { triggerBox = collider; + Debug.Log("Found Door trigger"); } else { boundingBox = collider; + Debug.Log("Found Door collider"); } } Unlock(); @@ -25,6 +30,7 @@ public class Door : MonoBehaviour { locked = true; boundingBox.enabled = true; triggerBox.enabled = false; + graphics.GetComponent().enabled = true; } public void Unlock() @@ -32,6 +38,7 @@ public class Door : MonoBehaviour { locked = false; boundingBox.enabled = false; triggerBox.enabled = true; + graphics.GetComponent().enabled = false; } public bool IsLocked() diff --git a/Assets/Scripts/Entities/Mob.cs b/Assets/Scripts/Entities/Mob.cs index a8ef325..34e2bc2 100644 --- a/Assets/Scripts/Entities/Mob.cs +++ b/Assets/Scripts/Entities/Mob.cs @@ -6,6 +6,7 @@ public abstract class Mob : Entity { readonly int maxHP; int currentHP; bool isDead; + int damage; // Constructor public Mob(EntityObjective referringObjective, int maxHP) : base(referringObjective) @@ -33,4 +34,14 @@ public abstract class Mob : Entity { if (!isDead) currentHP = (currentHP + healAmount > currentHP) ? maxHP : currentHP + healAmount; } + + public void SetDamage(int dmg) + { + damage = dmg; + } + + public int GetDamage() + { + return damage; + } } diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index 316b26b..5338c8c 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -14,6 +14,14 @@ public class Player : Mob { Debug.Log("Collision"); if (collision.collider.tag == "wall") { Kill(); + } else if (collision.collider.tag == "enemy") + { + Mob m = collision.collider.GetComponent(typeof(Mob)) as Mob; + if(m != null) + { + InflictDamage(m.GetDamage()); // TODO think about Mob attac mechanic + } + } } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 1a4cd5c..c9453f2 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -14,8 +14,11 @@ public class GameController : MonoBehaviour { [SerializeField] private GameObject ui; - private bool engineInitDone; + [SerializeField] + private GameObject cam; + private bool engineInitDone; + private Player player; public static GameController instance; public GameController() { @@ -28,7 +31,7 @@ public class GameController : MonoBehaviour { // Use this for initialization void Start () { - //ChangeState(GameState.INIT); + } // Update is called once per frame @@ -79,7 +82,10 @@ public class GameController : MonoBehaviour { playerPrefab }; start.SetObjective(new EntityObjective(start, tmp)); - start.OnPlayerEnter(); + start.GetObjective().Activate(); + player = ((EntityObjective) start.GetObjective()).GetEntities()[0].GetComponent(); + cam.GetComponent().SetFollow(player.gameObject); + ((EntityObjective)start.GetObjective()).Remove(player.gameObject); } private void Starting() diff --git a/Assets/Scripts/Objectives/EntityObjective.cs b/Assets/Scripts/Objectives/EntityObjective.cs index 7766378..2f401fa 100644 --- a/Assets/Scripts/Objectives/EntityObjective.cs +++ b/Assets/Scripts/Objectives/EntityObjective.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class EntityObjective : Objective{ +public class EntityObjective : Objective { List prefabList; List entityList; List spawnPointList; @@ -10,6 +10,7 @@ public class EntityObjective : Objective{ // Constructor public EntityObjective(Room objectiveCaller, List prefabList) : base(objectiveCaller) { + this.entityList = new List(); this.prefabList = prefabList; spawnPointList = objectiveCaller.GetSpawnpoints (); } @@ -24,6 +25,7 @@ public class EntityObjective : Objective{ Debug.Log("Instantiating Prefab"); GameObject tempObject = GameObject.Instantiate (i); tempObject.transform.position = spawnPointList [Random.Range (0, spawnPointList.Count)].position; + entityList.Add(tempObject); } objectiveCaller.Lock(); @@ -36,4 +38,9 @@ public class EntityObjective : Objective{ if (entityList.Count == 0) objectiveCaller.Unlock (); } + + public List GetEntities() + { + return entityList; + } } \ No newline at end of file diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index cad65f3..26d3ebe 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -1,38 +1,50 @@ -using UnityEngine; - -public class PlayerMovement : MonoBehaviour { - - [SerializeField] - public float acceleration = 3; - [SerializeField] - public float friction = 0.1f; - [SerializeField] - public float turnSpeed = 2; - [SerializeField] - public float drift = 1f; - [SerializeField] - public float brake = 2f; - - Rigidbody2D rigidbody2D; - - // Use this for initialization - void Start() { - rigidbody2D = GetComponent(); - } - - void FixedUpdate() { - Vector3 speedVec = new Vector3(rigidbody2D.velocity.x, rigidbody2D.velocity.y, 0); - float speed = speedVec.magnitude; - - { // Forward +using UnityEngine; + +public class PlayerMovement : MonoBehaviour { + private bool firstKeyPressed; + + [SerializeField] + public float acceleration = 3; + [SerializeField] + public float friction = 0.1f; + [SerializeField] + public float turnSpeed = 2; + [SerializeField] + public float drift = 1f; + [SerializeField] + public float brake = 2f; + + Rigidbody2D rigidbody2D; + + // Use this for initialization + void Start() { + rigidbody2D = GetComponent(); + } + + void Update() + { + if(!firstKeyPressed && Input.anyKey) + { + firstKeyPressed = true; + } + } + + void FixedUpdate() { + if (!firstKeyPressed) + return; + + Vector3 speedVec = new Vector3(rigidbody2D.velocity.x, rigidbody2D.velocity.y, 0); + float speed = speedVec.magnitude; + + { // Forward rigidbody2D.AddForce(transform.up * acceleration); } - {// Drag - Vector3 drag = speedVec.normalized * speed * speed * friction * -1; - if (Input.GetKey(KeyCode.S)) - drag *= brake; - rigidbody2D.AddForce(drag); - Debug.DrawLine(transform.position, transform.position + drag, Color.cyan, 0.01f, false); + {// Drag + Vector3 drag = speedVec.normalized * speed * speed * friction * -1; + if (Input.GetKey(KeyCode.S)) + drag *= brake; + rigidbody2D.AddForce(drag); + Debug.DrawLine(transform.position, transform.position + drag, Color.cyan, 0.01f, false); } { // Drift Vector3 forwardNorm = (transform.localRotation * Vector3.up).normalized * speedVec.magnitude; @@ -40,20 +52,20 @@ public class PlayerMovement : MonoBehaviour { br *= drift; rigidbody2D.AddForce(br); //Debug.Log(br); - Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false); - } - if (Input.GetKey(KeyCode.A)) + Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false); + } + if (Input.GetKey(KeyCode.A)) rigidbody2D.MoveRotation(rigidbody2D.rotation + turnSpeed); //transform.Rotate(Vector3.forward * turnSpeed); - if (Input.GetKey(KeyCode.D)) - rigidbody2D.MoveRotation(rigidbody2D.rotation - turnSpeed); - //transform.Rotate(Vector3.forward * -turnSpeed); - // Debug lines - Debug.DrawLine(transform.position, transform.position + speedVec, Color.magenta, 0.01f, false); + if (Input.GetKey(KeyCode.D)) + rigidbody2D.MoveRotation(rigidbody2D.rotation - turnSpeed); + //transform.Rotate(Vector3.forward * -turnSpeed); + // Debug lines + Debug.DrawLine(transform.position, transform.position + speedVec, Color.magenta, 0.01f, false); Debug.DrawLine(transform.position, transform.position + transform.localRotation * Vector3.up, Color.yellow, 0.01f, false); - //Debug.Log(transform.localRotation.eulerAngles); - //Debug.Log(transform.localRotation * Vector3.up); - //Debug.Log(curspeed); - } -} + //Debug.Log(transform.localRotation.eulerAngles); + //Debug.Log(transform.localRotation * Vector3.up); + //Debug.Log(curspeed); + } +} diff --git a/Assets/Scripts/Room.cs b/Assets/Scripts/Room.cs index 7975846..77d8951 100644 --- a/Assets/Scripts/Room.cs +++ b/Assets/Scripts/Room.cs @@ -37,6 +37,8 @@ public class Room : MonoBehaviour { } Debug.Log("Spawnpoints in Room: " + spawnpoints.Count); + + //Unlock(); } public void SetObjective(Objective o) @@ -60,13 +62,21 @@ public class Room : MonoBehaviour { } } + public Objective GetObjective() + { + return objective; + } + public void OnPlayerEnter() { - objective.Activate(); + if(objective != null) + objective.Activate(); } public List GetSpawnpoints() { return spawnpoints; } + + } diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs index 4bd1f99..f24bc95 100644 --- a/Assets/Scripts/UIController.cs +++ b/Assets/Scripts/UIController.cs @@ -2,30 +2,30 @@ using System.Collections.Generic; using UnityEngine; -public class UIController : MonoBehaviour { - - private GameObject score; +public class UIController : MonoBehaviour { + + private GameObject score; private GameObject pauseMenu; [SerializeField] - private GameObject gameOverPanel; - // Use this for initialization + private GameObject gameOverPanel; + // Use this for initialization void Start () { } // Update is called once per frame void Update () { - } - public static UIController instance; - - public void ShowPauseMenu() - { - pauseMenu.SetActive(true); - } - public void ClosePauseMenu() - { - pauseMenu.SetActive(false); + } + public static UIController instance; + + public void ShowPauseMenu() + { + pauseMenu.SetActive(true); } - + public void ClosePauseMenu() + { + pauseMenu.SetActive(false); + } + public void LoadSceneByIndex(int index) { Debug.Log("Loaded scene " + index); @@ -52,6 +52,6 @@ public class UIController : MonoBehaviour { } else { Debug.Log("No game over panel assigned"); } - } + } }