Add the Awake/Sleep contexts

This commit is contained in:
Patrice Vignola 2015-08-22 04:02:15 -04:00
parent 2af4b94ddc
commit a3fe31e09b
2 changed files with 15 additions and 3 deletions

View File

@ -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()

View File

@ -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);
}
}