diff --git a/Assets/Materials/LavaFloor.mat b/Assets/Materials/LavaFloor.mat new file mode 100644 index 0000000..d15539c Binary files /dev/null and b/Assets/Materials/LavaFloor.mat differ diff --git a/Assets/Materials/LavaFloor.mat.meta b/Assets/Materials/LavaFloor.mat.meta new file mode 100644 index 0000000..49b614b --- /dev/null +++ b/Assets/Materials/LavaFloor.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 17f1fb22be4247d4baff3f576a2cb9aa +timeCreated: 1440233010 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/NormalFloor.mat b/Assets/Materials/NormalFloor.mat new file mode 100644 index 0000000..6316788 Binary files /dev/null and b/Assets/Materials/NormalFloor.mat differ diff --git a/Assets/Materials/NormalFloor.mat.meta b/Assets/Materials/NormalFloor.mat.meta new file mode 100644 index 0000000..b1c4564 --- /dev/null +++ b/Assets/Materials/NormalFloor.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 32997c9d92ac99e4aa7f4a0f558d918e +timeCreated: 1440235608 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index 9102e2f..80ded23 100644 Binary files a/Assets/Prefabs/Child.prefab and b/Assets/Prefabs/Child.prefab differ diff --git a/Assets/Prefabs/Floor.prefab b/Assets/Prefabs/Floor.prefab new file mode 100644 index 0000000..8819686 Binary files /dev/null and b/Assets/Prefabs/Floor.prefab differ diff --git a/Assets/Prefabs/Floor.prefab.meta b/Assets/Prefabs/Floor.prefab.meta new file mode 100644 index 0000000..ca6123a --- /dev/null +++ b/Assets/Prefabs/Floor.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46cbd4a59ec21ba4d8adfffd70146cb7 +timeCreated: 1440235651 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/PatScene.unity b/Assets/Scenes/PatScene.unity index 8ab48f9..dae8fb5 100644 Binary files a/Assets/Scenes/PatScene.unity and b/Assets/Scenes/PatScene.unity differ diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index 00b4420..c58226f 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -2,12 +2,13 @@ using System.Collections; [RequireComponent(typeof(Rigidbody))] -public class Child : MonoBehaviour +public class Child : MonoBehaviour { public float Speed = 10f; public float JumpForce = 10f; public GameObject GroundCheck; public Pillow pillow; + public MomBehavior Mom; private Rigidbody _rb; private bool _isGrounded = false; @@ -37,6 +38,13 @@ public class Child : MonoBehaviour void Update() { _isGrounded = IsGrounded(); + + if (Mom.IsInRoom && !_isSleeping) + { + // TODO: Remove a life, kill the player, end the game, etc. + + Debug.Log("Player " + _index + " is being spotted by mom."); + } } void OnTriggerEnter(Collider other) { diff --git a/Assets/Scripts/Floor.cs b/Assets/Scripts/Floor.cs new file mode 100644 index 0000000..70e0792 --- /dev/null +++ b/Assets/Scripts/Floor.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System.Collections; + +[RequireComponent(typeof(MeshRenderer))] +public class Floor : MonoBehaviour +{ + public MomBehavior Mom; + public Material NormalMaterial; + public Material LavaMaterial; + + private MeshRenderer _renderer; + + void Awake() + { + _renderer = GetComponent(); + Mom.OnEnterRoom += ChangeToNormalFloor; + Mom.OnLeaveRoom += ChangeToLavaFloor; + } + + private void ChangeToNormalFloor() + { + _renderer.material = NormalMaterial; + } + + private void ChangeToLavaFloor() + { + _renderer.material = LavaMaterial; + } + + void OnDestroy() + { + Mom.OnEnterRoom -= ChangeToNormalFloor; + Mom.OnLeaveRoom -= ChangeToLavaFloor; + } +} diff --git a/Assets/Scripts/Floor.cs.meta b/Assets/Scripts/Floor.cs.meta new file mode 100644 index 0000000..7128f7e --- /dev/null +++ b/Assets/Scripts/Floor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 02652121580aeae49b2763bdc924ad87 +timeCreated: 1440233203 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/IMomObserver.cs b/Assets/Scripts/IMomObserver.cs new file mode 100644 index 0000000..5ad39b3 --- /dev/null +++ b/Assets/Scripts/IMomObserver.cs @@ -0,0 +1,8 @@ +using UnityEngine; +using System.Collections; + +public interface IMomObserver +{ + void NotifyWarning(); + void Notify(); +} diff --git a/Assets/Scripts/IMomObserver.cs.meta b/Assets/Scripts/IMomObserver.cs.meta new file mode 100644 index 0000000..e2b30e7 --- /dev/null +++ b/Assets/Scripts/IMomObserver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b12285e2e2df80d409ada81aa2ba22be +timeCreated: 1440233305 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MomBehavior.cs b/Assets/Scripts/MomBehavior.cs index 4c681b7..b6f95ac 100644 --- a/Assets/Scripts/MomBehavior.cs +++ b/Assets/Scripts/MomBehavior.cs @@ -1,24 +1,35 @@ using UnityEngine; using System.Collections; using UnityEngine.UI; +using System.Collections.Generic; +using System; public class MomBehavior : MonoBehaviour { - public Child[] Children; + public Action OnWarning; + public Action OnEnterRoom; + public Action OnLeaveRoom; public Text WarningText; public float MinTriggerTime = 60f; public float MaxTriggerTime = 90f; public float WarningHeadsupTime = 5f; + public float MotherStayTime = 2f; private float _elapsedTime = 0f; private float _nextTriggerTime; + private bool _isInRoom; + + public bool IsInRoom + { + get { return _isInRoom; } + } + void Awake() { _nextTriggerTime = GetNextTriggerTime(); - Debug.Log("NextTrigger: " + _nextTriggerTime); } void Update() @@ -30,23 +41,39 @@ public class MomBehavior : MonoBehaviour if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime) { WarningText.gameObject.SetActive(true); + + if (OnWarning != null) + { + OnWarning(); + } } else if (_elapsedTime >= _nextTriggerTime) { WarningText.gameObject.SetActive(false); _nextTriggerTime = GetNextTriggerTime(); - foreach (Child child in Children) - { - if (!child.IsSleeping) - { - // TODO: Do something (end the game? kill the player? make him lose 1 life? etc.) - - Debug.Log("Child " + child.Index + " got found by Mommy."); - } - } - _elapsedTime = 0f; + + StartCoroutine(StayInRoom()); + } + } + + private IEnumerator StayInRoom() + { + if (OnEnterRoom != null) + { + OnEnterRoom(); + } + + _isInRoom = true; + + yield return new WaitForSeconds(MotherStayTime); + + _isInRoom = false; + + if (OnLeaveRoom != null) + { + OnLeaveRoom(); } }