Add the ability to sleep on a bed anytime

This commit is contained in:
Patrice Vignola 2015-08-22 04:22:32 -04:00
parent f27b67061e
commit 0a1931c7d0
5 changed files with 14 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -62,7 +62,9 @@ public class Child : MonoBehaviour
private bool IsGrounded()
{
Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, 1 << LayerMask.NameToLayer("Ground"));
int mask = (1 << LayerMask.NameToLayer("Ground")) | (1 << LayerMask.NameToLayer("Bed"));
Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, mask);
return colliders.Length > 0;
}
@ -87,12 +89,21 @@ public class Child : MonoBehaviour
{
_isSleeping = IsOnBed();
// Temporary (only for visual cue until we get the animation)
if (_isSleeping)
{
transform.localEulerAngles = new Vector3(90f, transform.localEulerAngles.y, transform.localEulerAngles.z);
}
return _isSleeping;
}
public void WakeUp()
{
_isSleeping = false;
// Temporary (only for visual cue until we get the animation)
transform.localEulerAngles = new Vector3(0f, transform.localEulerAngles.y, transform.localEulerAngles.z);
}
private bool IsOnBed()

View File

@ -60,10 +60,12 @@ public class ChildController : MonoBehaviour
if (input.Actions.Contains("Sleep") && _child.Sleep())
{
Debug.Log("SLEEPING");
InputManager.Instance.PushActiveContext("Sleeping", (int)PlayerNumber);
}
else if (input.Actions.Contains("WakeUp"))
{
Debug.Log("AWAKE");
_child.WakeUp();
InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber);
}

Binary file not shown.