mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 09:00:58 +00:00
Merge branch 'master' of https://github.com/conjureets/pillowfight
Conflicts: Assets/Scripts/Child.cs Assets/Scripts/ChildController.cs
This commit is contained in:
commit
c4812ce7a2
Binary file not shown.
Binary file not shown.
@ -7,14 +7,28 @@ public class Child : MonoBehaviour
|
||||
public float Speed = 10f;
|
||||
public float JumpForce = 10f;
|
||||
public GameObject GroundCheck;
|
||||
public Pillow pillow;
|
||||
|
||||
private Rigidbody _rb;
|
||||
private bool _isGrounded = false;
|
||||
private float _xValue;
|
||||
private float _zValue;
|
||||
public Pillow pillow;
|
||||
private bool _isSleeping;
|
||||
public Transform target;
|
||||
|
||||
private int _index;
|
||||
|
||||
public int Index
|
||||
{
|
||||
get { return _index; }
|
||||
set { _index = value; }
|
||||
}
|
||||
|
||||
|
||||
public bool IsSleeping
|
||||
{
|
||||
get { return _isSleeping; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -29,11 +43,8 @@ public class Child : MonoBehaviour
|
||||
if (target != null) {
|
||||
transform.LookAt(target);
|
||||
}
|
||||
|
||||
//Debug.Log(_isGrounded);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
if (other.tag == "Pillow") {
|
||||
|
||||
@ -64,7 +75,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;
|
||||
}
|
||||
@ -84,4 +97,32 @@ public class Child : MonoBehaviour
|
||||
_rb.AddForce(new Vector3(0f, JumpForce, 0f));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Sleep()
|
||||
{
|
||||
_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()
|
||||
{
|
||||
Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, 1 << LayerMask.NameToLayer("Bed"));
|
||||
|
||||
return colliders.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,12 +15,13 @@ public class ChildController : MonoBehaviour
|
||||
|
||||
void Awake()
|
||||
{
|
||||
InputManager.Instance.PushActiveContext("Gameplay", (int)PlayerNumber);
|
||||
InputManager.Instance.PushActiveContext("Awake", (int)PlayerNumber);
|
||||
InputManager.Instance.AddCallback((int)PlayerNumber, HandlePlayerAxis);
|
||||
InputManager.Instance.AddCallback((int)PlayerNumber, HandlePlayerButtons);
|
||||
|
||||
_child = GetComponent<Child>();
|
||||
_autoTarget = GetComponent<AutoTarget>();
|
||||
_child.Index = (int)PlayerNumber;
|
||||
}
|
||||
|
||||
private void HandlePlayerAxis(MappedInput input)
|
||||
@ -88,6 +89,18 @@ public class ChildController : MonoBehaviour
|
||||
{
|
||||
_child.Jump();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
Assets/Scripts/MomBehavior.cs
Normal file
57
Assets/Scripts/MomBehavior.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MomBehavior : MonoBehaviour
|
||||
{
|
||||
public Child[] Children;
|
||||
|
||||
public Text WarningText;
|
||||
public float MinTriggerTime = 60f;
|
||||
public float MaxTriggerTime = 90f;
|
||||
public float WarningHeadsupTime = 5f;
|
||||
|
||||
private float _elapsedTime = 0f;
|
||||
|
||||
private float _nextTriggerTime;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_nextTriggerTime = GetNextTriggerTime();
|
||||
Debug.Log("NextTrigger: " + _nextTriggerTime);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// When the mom hasn't been triggered for a while, it can appear anytime between 2 borders
|
||||
|
||||
_elapsedTime += Time.deltaTime;
|
||||
|
||||
if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime)
|
||||
{
|
||||
WarningText.gameObject.SetActive(true);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private float GetNextTriggerTime()
|
||||
{
|
||||
return UnityEngine.Random.Range(MinTriggerTime, MaxTriggerTime);
|
||||
}
|
||||
}
|
||||
12
Assets/Scripts/MomBehavior.cs.meta
Normal file
12
Assets/Scripts/MomBehavior.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc7c5ec2b3918f14591f5f055ded72ef
|
||||
timeCreated: 1440227199
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user