mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +00:00
Merge branch 'master' of https://github.com/ConjureETS/PillowFight
Conflicts: Assets/Scripts/Child.cs
This commit is contained in:
commit
3327dc2f7d
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
public class AutoTarget : MonoBehaviour
|
||||
{
|
||||
private List<Transform> targets;
|
||||
public float minAngleRange = 20f;
|
||||
public float minAngleRange = 30f;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
|
||||
@ -25,7 +25,6 @@ public class Child : MonoBehaviour
|
||||
private bool _isSleeping;
|
||||
private float _invulnerableTime;
|
||||
private Bed _currentBed;
|
||||
public Transform target;
|
||||
private bool _isInLava;
|
||||
|
||||
private int _index;
|
||||
@ -46,6 +45,8 @@ public class Child : MonoBehaviour
|
||||
if (_numZ == 3) Die();
|
||||
}
|
||||
}
|
||||
private AutoTarget _autoTarget;
|
||||
|
||||
public int Index
|
||||
{
|
||||
get { return _index; }
|
||||
@ -62,6 +63,8 @@ public class Child : MonoBehaviour
|
||||
{
|
||||
_rb = GetComponent<Rigidbody>();
|
||||
AnimationPillow.SetActive(false);
|
||||
|
||||
_autoTarget = GetComponent<AutoTarget>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
@ -74,11 +77,7 @@ public class Child : MonoBehaviour
|
||||
Animator.SetBool("IsOnBed", GetBed());
|
||||
|
||||
_isGrounded = IsGrounded();
|
||||
Debug.Log(_isGrounded);
|
||||
// look at the target
|
||||
if (target != null) {
|
||||
transform.LookAt(target);
|
||||
}
|
||||
|
||||
|
||||
// We move the child depending on the camera orientation
|
||||
|
||||
@ -118,7 +117,20 @@ public class Child : MonoBehaviour
|
||||
|
||||
public void ThrowMecanimPillow()
|
||||
{
|
||||
Vector3 direction = target == null ? direction = transform.forward : target.transform.position - pillow.transform.position;
|
||||
if (pillow == null) return;
|
||||
|
||||
Transform target = _autoTarget.GetTarget(transform.forward);
|
||||
|
||||
Vector3 direction;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
direction = target.transform.position - pillow.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = transform.forward;
|
||||
}
|
||||
|
||||
direction = direction.normalized;
|
||||
|
||||
@ -132,6 +144,8 @@ public class Child : MonoBehaviour
|
||||
|
||||
pillow.IsOwned = false;
|
||||
|
||||
target = null;
|
||||
|
||||
pillow = null;
|
||||
}
|
||||
|
||||
@ -140,9 +154,21 @@ public class Child : MonoBehaviour
|
||||
|
||||
Pillow incomingPillow = other.GetComponent<Pillow>();
|
||||
|
||||
// picking up a pillow
|
||||
if (this.pillow == null && incomingPillow.IsPickable) {
|
||||
// getting hit by a pillow
|
||||
if (incomingPillow.IsThrown) {
|
||||
Debug.Log("abc");
|
||||
if (incomingPillow.Owner != this)
|
||||
{
|
||||
//player is hit
|
||||
Debug.Log("Child is hit by a pillow");
|
||||
|
||||
Push(other.GetComponent<Rigidbody>().velocity.normalized * 10 * hitPushBackForce);
|
||||
Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
// picking up a pillow
|
||||
else if (this.pillow == null && incomingPillow.IsPickable) {
|
||||
Debug.Log("def");
|
||||
pillow = incomingPillow;
|
||||
|
||||
pillow.transform.parent = transform; // make the pillow a child of Child
|
||||
@ -154,19 +180,6 @@ public class Child : MonoBehaviour
|
||||
|
||||
// TODO: place the pillow correctly or animate or something...
|
||||
}
|
||||
|
||||
// getting hit by a pillow
|
||||
else if (incomingPillow.IsThrown) {
|
||||
|
||||
if (pillow.Owner != null && pillow.Owner != this)
|
||||
{
|
||||
//player is hit
|
||||
Debug.Log("Child is hit by a pillow");
|
||||
|
||||
Push(other.GetComponent<Rigidbody>().velocity.normalized * 10 * hitPushBackForce);
|
||||
Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +242,7 @@ public class Child : MonoBehaviour
|
||||
return colliders.Length > 0 ? colliders[0].GetComponent<Bed>() : null;
|
||||
}
|
||||
|
||||
internal void Throw() {
|
||||
public void Throw() {
|
||||
if (_isInLava) return;
|
||||
|
||||
if (pillow != null) {
|
||||
@ -272,11 +285,6 @@ public class Child : MonoBehaviour
|
||||
|
||||
void OnCollisionStay(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.tag == "Walls")
|
||||
{
|
||||
Debug.Log(_isPushed);
|
||||
}
|
||||
|
||||
if (collision.gameObject.tag == "Lava")
|
||||
{
|
||||
_invulnerableTime += Time.deltaTime;
|
||||
@ -295,9 +303,10 @@ public class Child : MonoBehaviour
|
||||
}
|
||||
else if (_wasPushed && collision.gameObject.tag == "Walls")
|
||||
{
|
||||
/*
|
||||
_wasPushed = false;
|
||||
|
||||
Push(Vector3.Reflect(_pushedDir.normalized, collision.contacts[0].normal) * _pushedDir.magnitude);
|
||||
Push(Vector3.Reflect(_pushedDir.normalized, collision.contacts[0].normal) * _pushedDir.magnitude);*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,4 +346,4 @@ public class Child : MonoBehaviour
|
||||
{
|
||||
ActivateVibration(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,23 +75,15 @@ public class ChildController : MonoBehaviour
|
||||
}
|
||||
|
||||
if (xLookingValue != 0 || zLookingValue != 0) {
|
||||
//Transform target = _autoTarget.GetTarget(new Vector3(xLookingValue, 0, zLookingValue));
|
||||
Transform target = _autoTarget.GetTarget(xLookingValue, zLookingValue);
|
||||
|
||||
_child.target = target;
|
||||
if (_child.target != null) {
|
||||
transform.LookAt(_child.target);
|
||||
}
|
||||
else {
|
||||
transform.eulerAngles = new Vector3(
|
||||
transform.eulerAngles = new Vector3(
|
||||
transform.eulerAngles.x,
|
||||
Mathf.Atan2(xLookingValue, zLookingValue) * Mathf.Rad2Deg -90, // -90 to correct forward facing angle...
|
||||
transform.eulerAngles.z);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
_child.target = null; // no auto targeting when not actively pressing the joystick in a direction
|
||||
|
||||
|
||||
// if player is not look with the right joystick, then face the direction we're going
|
||||
// if left joystick is used, else we don't change the facing direction
|
||||
if (xValue != 0 || zValue!= 0) {
|
||||
|
||||
@ -80,7 +80,10 @@ public class Pillow : MonoBehaviour {
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision other) {
|
||||
if (!IsPickable && !IsLost) {
|
||||
Child child = other.gameObject.GetComponent<Child>();
|
||||
|
||||
if (!IsPickable && !IsLost && Owner == child)
|
||||
{
|
||||
// on first collision, revert the pillow as pickable
|
||||
MakePickable();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user