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
This commit is contained in:
commit
d6d7357663
13
Assets/MecanimContainer.cs
Normal file
13
Assets/MecanimContainer.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class MecanimContainer : MonoBehaviour
|
||||
{
|
||||
public Child ImmediateParent;
|
||||
|
||||
// For Mecanim
|
||||
public void throw_pillow()
|
||||
{
|
||||
ImmediateParent.ThrowMecanimPillow();
|
||||
}
|
||||
}
|
||||
12
Assets/MecanimContainer.cs.meta
Normal file
12
Assets/MecanimContainer.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d248c94f1991a74ba25229de4e648ea
|
||||
timeCreated: 1440351256
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -115,27 +115,50 @@ 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<Pillow>();
|
||||
|
||||
// picking up a pillow
|
||||
if (this.pillow == null && incomingPillow.IsPickable) {
|
||||
|
||||
pillow = incomingPillow;
|
||||
|
||||
pillow.transform.parent = transform; // make the pillow a child of Child
|
||||
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.IsOwned = true;
|
||||
|
||||
// TODO: place the pillow correctly or animate or something...
|
||||
}
|
||||
|
||||
// getting hit by a pillow
|
||||
else if (incomingPillow.IsThrown) {
|
||||
|
||||
if (incomingPillow.IsThrown) {
|
||||
Debug.Log("abc");
|
||||
if (incomingPillow.Owner != this)
|
||||
{
|
||||
//player is hit
|
||||
Debug.Log("Child is hit by a pillow");
|
||||
|
||||
@ -143,6 +166,21 @@ public class Child : MonoBehaviour
|
||||
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.gameObject.SetActive(false);
|
||||
pillow.GetComponent<Rigidbody>().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...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsGrounded()
|
||||
@ -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);*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<Collider>();
|
||||
@ -71,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