diff --git a/Assets/MecanimContainer.cs b/Assets/MecanimContainer.cs new file mode 100644 index 0000000..86bbf21 --- /dev/null +++ b/Assets/MecanimContainer.cs @@ -0,0 +1,13 @@ +using UnityEngine; +using System.Collections; + +public class MecanimContainer : MonoBehaviour +{ + public Child ImmediateParent; + + // For Mecanim + public void throw_pillow() + { + ImmediateParent.ThrowMecanimPillow(); + } +} diff --git a/Assets/MecanimContainer.cs.meta b/Assets/MecanimContainer.cs.meta new file mode 100644 index 0000000..c9daa61 --- /dev/null +++ b/Assets/MecanimContainer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d248c94f1991a74ba25229de4e648ea +timeCreated: 1440351256 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index c8330af..09df4f7 100644 --- a/Assets/Prefabs/Child.prefab +++ b/Assets/Prefabs/Child.prefab @@ -417,6 +417,7 @@ GameObject: m_Component: - 4: {fileID: 436644} - 95: {fileID: 9580008} + - 114: {fileID: 11484968} m_Layer: 0 m_Name: Container m_TagString: Untagged @@ -1084,7 +1085,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e6ffb35a11ff1f545ac22f7ea752cffb, type: 3} m_Name: m_EditorClassIdentifier: - PlayerNumber: 1 + PlayerNumber: 0 --- !u!114 &11474836 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1097,6 +1098,18 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: minAngleRange: 10 +--- !u!114 &11484968 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 166010} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4d248c94f1991a74ba25229de4e648ea, type: 3} + m_Name: + m_EditorClassIdentifier: + ImmediateParent: {fileID: 11430644} --- !u!135 &13545904 SphereCollider: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/Kid_AnimControl.controller b/Assets/Prefabs/Kid_AnimControl.controller index fe32a51..789e89b 100644 --- a/Assets/Prefabs/Kid_AnimControl.controller +++ b/Assets/Prefabs/Kid_AnimControl.controller @@ -70,7 +70,7 @@ AnimatorStateTransition: m_TransitionDuration: .25 m_TransitionOffset: 0 m_ExitTime: .659090877 - m_HasExitTime: 1 + m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index 9dfd389..7264140 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -2595,10 +2595,6 @@ Prefab: propertyPath: m_Name value: Child 1 objectReference: {fileID: 0} - - target: {fileID: 11446734, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: PlayerNumber - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index f25f50b..7587eb2 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -115,33 +115,71 @@ public class Child : MonoBehaviour } } + public void ThrowMecanimPillow() + { + 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; + + pillow.gameObject.SetActive(true); + pillow.transform.localPosition = new Vector3(0.109f, -0.407f, 0.389f); + pillow.transform.localEulerAngles = new Vector3(0f, 204.46f, 310.0002f); + + AnimationPillow.SetActive(false); + + pillow.Throw(direction * ThrowForce); + + pillow.IsOwned = false; + + target = null; + + pillow = null; + } + void OnTriggerEnter(Collider other) { if (other.tag == "Pillow"){ Pillow incomingPillow = other.GetComponent(); - // 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().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 - pillow.transform.localPosition = new Vector3(0f, 1.5f, 0f); + pillow.gameObject.SetActive(false); pillow.GetComponent().isKinematic = true; // dont make pillow obey to gravity when in a child's hands pillow.IsOwned = true; + pillow.Owner = this; + AnimationPillow.SetActive(true); // TODO: place the pillow correctly or animate or something... } - - // getting hit by a pillow - else if (incomingPillow.IsThrown) { - - //player is hit - Debug.Log("Child is hit by a pillow"); - - Push( other.GetComponent().velocity.normalized * 10 * hitPushBackForce); - Destroy(other.gameObject); - } } } @@ -208,27 +246,6 @@ public class Child : MonoBehaviour if (_isInLava) return; if (pillow != null) { - - Vector3 direction; - - Transform target = _autoTarget.GetTarget(transform.forward); - - if (target != null) { - direction = target.transform.position - pillow.transform.position; - } - else { - direction = transform.forward; - } - direction = direction.normalized; - - - pillow.Throw(direction * ThrowForce); - - pillow.IsOwned = false; - - pillow = null; - - target = null; Animator.SetTrigger("StartAttack"); } } @@ -268,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; @@ -291,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);*/ } } @@ -333,4 +346,4 @@ public class Child : MonoBehaviour { ActivateVibration(false); } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Pillow.cs b/Assets/Scripts/Pillow.cs index 6c9cf1b..fb7ee3e 100644 --- a/Assets/Scripts/Pillow.cs +++ b/Assets/Scripts/Pillow.cs @@ -31,6 +31,15 @@ public class Pillow : MonoBehaviour { } } + private Child _owner; + + public Child Owner + { + get { return _owner; } + set { _owner = value; } + } + + // Use this for initialization void Start () { _col = GetComponent(); @@ -71,7 +80,10 @@ public class Pillow : MonoBehaviour { } void OnCollisionEnter(Collision other) { - if (!IsPickable && !IsLost) { + Child child = other.gameObject.GetComponent(); + + if (!IsPickable && !IsLost && Owner == child) + { // on first collision, revert the pillow as pickable MakePickable(); }