mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-26 10:00:58 +00:00
Merge branch 'master' of https://github.com/ConjureETS/PillowFight
Conflicts: Assets/Scenes/PatScene.unity Added the mother sprite Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
commit
3da3a00efc
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,13 +3,87 @@ using System.Collections;
|
|||||||
|
|
||||||
public class Bed : MonoBehaviour
|
public class Bed : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
// Values to balance out in playtesting
|
||||||
|
public float MinSpawnDelay = 7f;
|
||||||
|
public float MaxSpawnDelay = 15f;
|
||||||
|
|
||||||
|
public Pillow PillowObject;
|
||||||
|
public Vector3 RelativePosition = new Vector3(1.6f, 0.5f, 0f);
|
||||||
|
|
||||||
private bool _isTaken;
|
private bool _isTaken;
|
||||||
|
private Pillow _currentPillow;
|
||||||
|
private float _elapsedTime;
|
||||||
|
|
||||||
|
private float _nextSpawnDelay;
|
||||||
|
|
||||||
public bool IsTaken
|
public bool IsTaken
|
||||||
{
|
{
|
||||||
get { return _isTaken; }
|
get { return _isTaken; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
SpawnPillow();
|
||||||
|
|
||||||
|
_nextSpawnDelay = GetNextSpawnDelay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (_currentPillow == null)
|
||||||
|
{
|
||||||
|
_elapsedTime += Time.deltaTime;
|
||||||
|
|
||||||
|
if (_elapsedTime >= _nextSpawnDelay)
|
||||||
|
{
|
||||||
|
_elapsedTime = 0f;
|
||||||
|
SpawnPillow();
|
||||||
|
_nextSpawnDelay = GetNextSpawnDelay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_currentPillow.IsOwned)
|
||||||
|
{
|
||||||
|
_currentPillow = null;
|
||||||
|
_elapsedTime = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpawnPillow()
|
||||||
|
{
|
||||||
|
_currentPillow = Instantiate(PillowObject, transform.position, PillowObject.transform.rotation) as Pillow;
|
||||||
|
|
||||||
|
Vector3 rot = _currentPillow.transform.eulerAngles;
|
||||||
|
rot.y = transform.eulerAngles.y - 90f;
|
||||||
|
|
||||||
|
_currentPillow.transform.eulerAngles = rot;
|
||||||
|
|
||||||
|
Vector3 pos = new Vector3();
|
||||||
|
|
||||||
|
if (Mathf.Approximately(transform.eulerAngles.y, 0f))
|
||||||
|
{
|
||||||
|
pos = RelativePosition;
|
||||||
|
}
|
||||||
|
else if (Mathf.Approximately(transform.eulerAngles.y, 90f))
|
||||||
|
{
|
||||||
|
pos = new Vector3(-RelativePosition.z, RelativePosition.y, -RelativePosition.x);
|
||||||
|
}
|
||||||
|
else if (Mathf.Approximately(transform.eulerAngles.y, 180f))
|
||||||
|
{
|
||||||
|
pos = new Vector3(-RelativePosition.x, RelativePosition.y, -RelativePosition.z);
|
||||||
|
}
|
||||||
|
else if (Mathf.Approximately(transform.eulerAngles.y, 270f))
|
||||||
|
{
|
||||||
|
pos = new Vector3(RelativePosition.z, RelativePosition.y, RelativePosition.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentPillow.transform.position += pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float GetNextSpawnDelay()
|
||||||
|
{
|
||||||
|
return UnityEngine.Random.Range(MinSpawnDelay, MaxSpawnDelay);
|
||||||
|
}
|
||||||
|
|
||||||
public void Take()
|
public void Take()
|
||||||
{
|
{
|
||||||
_isTaken = true;
|
_isTaken = true;
|
||||||
@ -19,4 +93,31 @@ public class Bed : MonoBehaviour
|
|||||||
{
|
{
|
||||||
_isTaken = false;
|
_isTaken = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void OnCollisionEnter(Collision col)
|
||||||
|
{
|
||||||
|
// TODO: Check if the pillow is owned (otherwise it means the collision is only a player walking by)
|
||||||
|
if (col.gameObject.tag == "Pillow" && _currentPillow == null)
|
||||||
|
{
|
||||||
|
_currentPillow = col.gameObject.GetComponent<Pillow>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCollisionExit(Collision col)
|
||||||
|
{
|
||||||
|
if (_currentPillow != null && col.gameObject == _currentPillow.gameObject)
|
||||||
|
{
|
||||||
|
_currentPillow = null;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
void OnCollisionStay(Collision col)
|
||||||
|
{
|
||||||
|
if (col.gameObject.tag == "Player")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,7 @@ public class Child : MonoBehaviour
|
|||||||
pillow.transform.parent = transform; // make the pillow a child of Child
|
pillow.transform.parent = transform; // make the pillow a child of Child
|
||||||
pillow.transform.localPosition = new Vector3(0f, 1.5f, 0f);
|
pillow.transform.localPosition = new Vector3(0f, 1.5f, 0f);
|
||||||
pillow.GetComponent<Rigidbody>().isKinematic = true; // dont make pillow obey to gravity when in a child's hands
|
pillow.GetComponent<Rigidbody>().isKinematic = true; // dont make pillow obey to gravity when in a child's hands
|
||||||
|
pillow.IsOwned = true;
|
||||||
|
|
||||||
// TODO: place the pillow correctly or animate or something...
|
// TODO: place the pillow correctly or animate or something...
|
||||||
}
|
}
|
||||||
@ -189,6 +190,8 @@ public class Child : MonoBehaviour
|
|||||||
|
|
||||||
pillow.Throw(direction * ThrowForce);
|
pillow.Throw(direction * ThrowForce);
|
||||||
|
|
||||||
|
pillow.IsOwned = false;
|
||||||
|
|
||||||
pillow = null;
|
pillow = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,13 @@ public class Pillow : MonoBehaviour {
|
|||||||
private Collider _col;
|
private Collider _col;
|
||||||
private Rigidbody _rb;
|
private Rigidbody _rb;
|
||||||
|
|
||||||
|
private bool _isOwned;
|
||||||
|
|
||||||
|
public bool IsOwned
|
||||||
|
{
|
||||||
|
get { return _isOwned; }
|
||||||
|
set { _isOwned = value; }
|
||||||
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user