From a3fe31e09b5070f8ff1b4ad54ff3c361bfd2c534 Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sat, 22 Aug 2015 04:02:15 -0400 Subject: [PATCH] Add the Awake/Sleep contexts --- Assets/Scripts/Child.cs | 9 ++++++++- Assets/Scripts/ChildController.cs | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index 77ce71a..5846c8a 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -83,9 +83,16 @@ public class Child : MonoBehaviour } } - public void Sleep() + public bool Sleep() { _isSleeping = IsOnBed(); + + return _isSleeping; + } + + public void WakeUp() + { + _isSleeping = false; } private bool IsOnBed() diff --git a/Assets/Scripts/ChildController.cs b/Assets/Scripts/ChildController.cs index 8c4cef5..70c6ede 100644 --- a/Assets/Scripts/ChildController.cs +++ b/Assets/Scripts/ChildController.cs @@ -58,9 +58,14 @@ public class ChildController : MonoBehaviour _child.Jump(); } - if (input.Actions.Contains("Sleep")) + if (input.Actions.Contains("Sleep") && _child.Sleep()) { - _child.Sleep(); + InputManager.Instance.PushActiveContext("Sleeping", (int)PlayerNumber); + } + else if (input.Actions.Contains("WakeUp")) + { + _child.WakeUp(); + InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber); } }