diff --git a/Assets/Prefabs/Canvas.prefab b/Assets/Prefabs/Canvas.prefab index 383b274..3d1e09d 100644 --- a/Assets/Prefabs/Canvas.prefab +++ b/Assets/Prefabs/Canvas.prefab @@ -164,7 +164,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_Sprite: {fileID: 0} m_Type: 0 - m_PreserveAspect: 0 + m_PreserveAspect: 1 m_FillCenter: 1 m_FillMethod: 4 m_FillAmount: 1 @@ -185,7 +185,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_Sprite: {fileID: 0} m_Type: 0 - m_PreserveAspect: 0 + m_PreserveAspect: 1 m_FillCenter: 1 m_FillMethod: 4 m_FillAmount: 1 @@ -214,8 +214,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: WarningText: {fileID: 11404408} - MinTriggerTime: 30 - MaxTriggerTime: 45 + MinTriggerTime: 20 + MaxTriggerTime: 30 WarningHeadsupTime: 5 MotherStayTime: 5 RoomDoor: {fileID: 0} @@ -237,7 +237,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_Sprite: {fileID: 0} m_Type: 0 - m_PreserveAspect: 0 + m_PreserveAspect: 1 m_FillCenter: 1 m_FillMethod: 4 m_FillAmount: 1 @@ -312,7 +312,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_Sprite: {fileID: 0} m_Type: 0 - m_PreserveAspect: 0 + m_PreserveAspect: 1 m_FillCenter: 1 m_FillMethod: 4 m_FillAmount: 1 @@ -415,10 +415,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 22413388} m_RootOrder: 4 - m_AnchorMin: {x: 1, y: 0} - m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -84.5, y: 108} - m_SizeDelta: {x: 169, y: 216} + m_AnchorMin: {x: .810000002, y: 0} + m_AnchorMax: {x: 1, y: .300000012} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: .5, y: .5} --- !u!224 &22441784 RectTransform: @@ -467,10 +467,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 22413388} m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 90, y: -113} - m_SizeDelta: {x: 169, y: 216} + m_AnchorMin: {x: 0, y: .699999988} + m_AnchorMax: {x: .189999998, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: .5, y: .5} --- !u!224 &22484266 RectTransform: @@ -485,9 +485,9 @@ RectTransform: m_Father: {fileID: 22413388} m_RootOrder: 3 m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 84.5, y: 108} - m_SizeDelta: {x: 169, y: 216} + m_AnchorMax: {x: .189999998, y: .300000012} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: .5, y: .5} --- !u!224 &22497504 RectTransform: @@ -501,10 +501,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 22413388} m_RootOrder: 2 - m_AnchorMin: {x: 1, y: 1} + m_AnchorMin: {x: .810000002, y: .699999988} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -84.5, y: -108} - m_SizeDelta: {x: 169, y: 216} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: .5, y: .5} --- !u!1001 &100100000 Prefab: diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index 66b2efc..66ad268 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -608,6 +608,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 88e55981fb5053743beab34a961a19e6, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &638369586 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11406004, guid: 7b2324b0ba2cbba47a32db098a5a4a3b, + type: 2} + m_PrefabInternal: {fileID: 488401107} + m_Script: {fileID: 11500000, guid: dd2c12784e85d194ca7216a12233e1fa, type: 3} --- !u!1001 &673576178 Prefab: m_ObjectHideFlags: 0 @@ -645,7 +651,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 22413388, guid: dec23153e975cb94db47e642092ad58e, type: 2} propertyPath: m_RootOrder - value: 10 + value: 9 objectReference: {fileID: 0} - target: {fileID: 22413388, guid: dec23153e975cb94db47e642092ad58e, type: 2} propertyPath: m_AnchoredPosition.x @@ -691,146 +697,14 @@ Prefab: propertyPath: RoomDoor value: objectReference: {fileID: 544939640} - - target: {fileID: 120876, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.x - value: .189999998 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMin.y - value: .699999988 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22456076, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11406010, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_PreserveAspect - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 188232, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMin.y - value: .699999988 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMin.x - value: .810000002 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22497504, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 141632, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.x - value: .189999998 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.y - value: .300000012 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22484266, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11406500, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_PreserveAspect - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11458950, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_PreserveAspect - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 180592, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMin.x - value: .810000002 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchorMax.y - value: .300000012 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22436868, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11494372, guid: dec23153e975cb94db47e642092ad58e, type: 2} - propertyPath: m_PreserveAspect - value: 1 - objectReference: {fileID: 0} + - target: {fileID: 11451246, guid: dec23153e975cb94db47e642092ad58e, type: 2} + propertyPath: Children.Array.data[0] + value: + objectReference: {fileID: 981569108} + - target: {fileID: 11451246, guid: dec23153e975cb94db47e642092ad58e, type: 2} + propertyPath: Children.Array.data[1] + value: + objectReference: {fileID: 638369586} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: dec23153e975cb94db47e642092ad58e, type: 2} m_IsPrefabParent: 0 @@ -1220,10 +1094,6 @@ Prefab: propertyPath: m_RootOrder value: 2 objectReference: {fileID: 0} - - target: {fileID: 6472040, guid: 0839912c1546d474686e48f2f1ea76fe, type: 2} - propertyPath: m_Material - value: - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 0839912c1546d474686e48f2f1ea76fe, type: 2} m_IsPrefabParent: 0 @@ -1273,6 +1143,12 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 9f2c38d0d3154bc4d8148a949b98af28, type: 2} m_IsPrefabParent: 0 +--- !u!114 &981569108 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, + type: 2} + m_PrefabInternal: {fileID: 1928589739} + m_Script: {fileID: 11500000, guid: dd2c12784e85d194ca7216a12233e1fa, type: 3} --- !u!1001 &987851018 Prefab: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/AutoTarget.cs b/Assets/Scripts/AutoTarget.cs index 0ed8fef..59a66cb 100644 --- a/Assets/Scripts/AutoTarget.cs +++ b/Assets/Scripts/AutoTarget.cs @@ -47,13 +47,13 @@ public class AutoTarget : MonoBehaviour public Transform GetTarget(Vector3 lookingAngle) { - return GetTarget(lookingAngle, 2000, minAngleRange); - } - - public Transform GetTarget(Vector3 lookingAngle, float range, float minAngle) - { + return GetTarget(lookingAngle, 2000, minAngleRange); + } + + public Transform GetTarget(Vector3 lookingAngle, float range, float minAngle) + { Transform closest = null; - float rangeSq = range * range; + float rangeSq = range * range; //Debug.Log("looking direction:" + lookingAngle); Debug.DrawRay(transform.position, lookingAngle * 2); @@ -61,12 +61,12 @@ public class AutoTarget : MonoBehaviour foreach (Transform t in targets) { - if (t == null) continue; - + if (t == null) continue; + Vector3 targetDirection = t.transform.position - transform.position; - Debug.Log(targetDirection.magnitude); - if (targetDirection.sqrMagnitude > rangeSq) - continue; + Debug.Log(targetDirection.magnitude); + if (targetDirection.sqrMagnitude > rangeSq) + continue; float realAngle = Mathf.Atan2(targetDirection.z, targetDirection.x) * Mathf.Rad2Deg; diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index 40c0db8..5702c07 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -1,254 +1,254 @@ -using UnityEngine; -using System.Collections; - -[RequireComponent(typeof(Rigidbody))] -public class Child : MonoBehaviour -{ - public float Speed = 10f; - public float JumpForce = 10f; - public float MaxInvulnerableTime = 2f; +using UnityEngine; +using System.Collections; + +[RequireComponent(typeof(Rigidbody))] +public class Child : MonoBehaviour +{ + public float Speed = 10f; + public float JumpForce = 10f; + public float MaxInvulnerableTime = 2f; public float ThrowForce = 30f; - public float HitForce = 3f; - public float hitPushBackForce = 250f; - public float yAngleVector = 9f; - - public GameObject GroundCheck; - public Pillow pillow; - public MomBehavior Mom; - public PlayerAvatar Avatar; - public Animator Animator; - public GameObject AnimationPillow; - - private Rigidbody _rb; - private bool _isGrounded = false; - private float _xValue; - private float _zValue; - private bool _isSleeping; - private float _invulnerableTime; - private Bed _currentBed; - private bool _isInLava; - - private int _index; - private bool _isPushed = false; - private bool _wasPushed = false; - private Vector3 _pushedDir; - - private float _stunTime; - - private int _numZ = 0; - public int NumZ - { - get { return _numZ; } - set - { - _numZ = value; - Avatar.NumZ = _numZ; - if (_numZ == 3) Die(); - } - } - private AutoTarget _autoTarget; - - public int Index - { - get { return _index; } - set { _index = value; } - } - - - public bool IsSleeping - { - get { return _isSleeping; } - } - - void Awake() - { - _rb = GetComponent(); - AnimationPillow.SetActive(false); - - _autoTarget = GetComponent(); - } - - void Start() - { - Avatar.PlayerNum = Index + 1; - } - - void Update() - { - Animator.SetBool("IsOnBed", GetBed()); - - _isGrounded = IsGrounded(); - - - // We move the child depending on the camera orientation - - if (_stunTime >= Time.deltaTime * 3f && _wasPushed && _rb.velocity == Vector3.zero) - { - _wasPushed = false; - } - - if (_isPushed) - { - _stunTime += Time.deltaTime; - - if (_stunTime >= Time.deltaTime * 3f && _rb.velocity == Vector3.zero) - { - _isPushed = false; - _wasPushed = true; - } - } - else - { - _stunTime = 0f; - Vector3 forwardDir = Camera.main.transform.forward; - Vector3 rightDir = Camera.main.transform.right; - - forwardDir.y = 0f; - forwardDir = forwardDir.normalized * _zValue * Speed; - - rightDir.y = 0f; - rightDir = rightDir.normalized * _xValue * Speed; - - Vector3 movement = forwardDir + rightDir; - movement.y = _rb.velocity.y; - - _rb.velocity = movement; - } - } - - 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(); - - // 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.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... - } - } - } - - private bool IsGrounded() - { - int mask = (1 << LayerMask.NameToLayer("Ground")) | (1 << LayerMask.NameToLayer("Bed")); - - Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, mask); - - return colliders.Length > 0; - } - - public void Move(float xValue, float zValue) - { - _xValue = xValue; - _zValue = zValue; - } - - public void Jump() - { - if (_isGrounded) - { - _isGrounded = false; - - _rb.AddForce(new Vector3(0f, JumpForce, 0f)); - - Animator.SetTrigger("jump"); - } - } - - public bool Sleep() - { - Bed bed = GetBed(); - - if (bed != null && !bed.IsTaken) - { - _currentBed = bed; - bed.Take(); - _isSleeping = true; - Animator.SetBool("IsSleeping", true); - } - - return _isSleeping; - } - - public void WakeUp() - { - _isSleeping = false; - Animator.SetBool("IsSleeping", false); - - _currentBed.Leave(); - - _currentBed = null; - } - - public Bed GetBed() - { - Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, 1 << LayerMask.NameToLayer("Bed")); - - return colliders.Length > 0 ? colliders[0].GetComponent() : null; - } - - public void Throw() { - if (_isInLava) return; - - if (pillow != null) { - Animator.SetTrigger("StartAttack"); - } + public float HitForce = 3f; + public float hitPushBackForce = 250f; + public float yAngleVector = 9f; + + public GameObject GroundCheck; + public Pillow pillow; + public MomBehavior Mom; + public PlayerAvatar Avatar; + public Animator Animator; + public GameObject AnimationPillow; + + private Rigidbody _rb; + private bool _isGrounded = false; + private float _xValue; + private float _zValue; + private bool _isSleeping; + private float _invulnerableTime; + private Bed _currentBed; + private bool _isInLava; + + private int _index; + private bool _isPushed = false; + private bool _wasPushed = false; + private Vector3 _pushedDir; + + private float _stunTime; + + private int _numZ = 0; + public int NumZ + { + get { return _numZ; } + set + { + _numZ = value; + Avatar.NumZ = _numZ; + if (_numZ == 3) Die(); + } + } + private AutoTarget _autoTarget; + + public int Index + { + get { return _index; } + set { _index = value; } + } + + + public bool IsSleeping + { + get { return _isSleeping; } + } + + void Awake() + { + _rb = GetComponent(); + AnimationPillow.SetActive(false); + + _autoTarget = GetComponent(); + } + + void Start() + { + Avatar.PlayerNum = Index + 1; + } + + void Update() + { + Animator.SetBool("IsOnBed", GetBed()); + + _isGrounded = IsGrounded(); + + + // We move the child depending on the camera orientation + + if (_stunTime >= Time.deltaTime * 3f && _wasPushed && _rb.velocity == Vector3.zero) + { + _wasPushed = false; + } + + if (_isPushed) + { + _stunTime += Time.deltaTime; + + if (_stunTime >= Time.deltaTime * 3f && _rb.velocity == Vector3.zero) + { + _isPushed = false; + _wasPushed = true; + } + } + else + { + _stunTime = 0f; + Vector3 forwardDir = Camera.main.transform.forward; + Vector3 rightDir = Camera.main.transform.right; + + forwardDir.y = 0f; + forwardDir = forwardDir.normalized * _zValue * Speed; + + rightDir.y = 0f; + rightDir = rightDir.normalized * _xValue * Speed; + + Vector3 movement = forwardDir + rightDir; + movement.y = _rb.velocity.y; + + _rb.velocity = movement; + } + } + + 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(); + + // 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.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... + } + } + } + + private bool IsGrounded() + { + int mask = (1 << LayerMask.NameToLayer("Ground")) | (1 << LayerMask.NameToLayer("Bed")); + + Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, mask); + + return colliders.Length > 0; + } + + public void Move(float xValue, float zValue) + { + _xValue = xValue; + _zValue = zValue; + } + + public void Jump() + { + if (_isGrounded) + { + _isGrounded = false; + + _rb.AddForce(new Vector3(0f, JumpForce, 0f)); + + Animator.SetTrigger("jump"); + } + } + + public bool Sleep() + { + Bed bed = GetBed(); + + if (bed != null && !bed.IsTaken) + { + _currentBed = bed; + bed.Take(); + _isSleeping = true; + Animator.SetBool("IsSleeping", true); + } + + return _isSleeping; + } + + public void WakeUp() + { + _isSleeping = false; + Animator.SetBool("IsSleeping", false); + + _currentBed.Leave(); + + _currentBed = null; + } + + public Bed GetBed() + { + Collider[] colliders = Physics.OverlapSphere(GroundCheck.transform.position, 0.149f, 1 << LayerMask.NameToLayer("Bed")); + + return colliders.Length > 0 ? colliders[0].GetComponent() : null; + } + + public void Throw() { + if (_isInLava) return; + + if (pillow != null) { + Animator.SetTrigger("StartAttack"); + } } public void Swing() @@ -267,102 +267,105 @@ public class Child : MonoBehaviour direction = direction.normalized; t.gameObject.GetComponent().Push(direction * HitForce); - } - - - void OnCollisionEnter(Collision collision) - { - if (collision.gameObject.tag == "Lava") - { - Debug.Log("Player " + _index + " entered lava. Lose one life."); - TakeLavaDamage(); - ActivateVibration(true); - Animator.SetBool("IsOnLava", true); - _isInLava = true; - } - else - { - // Setup for the next time the player falls on the lava - //_invulnerableTime = MaxInvulnerableTime; - - if (collision.gameObject.tag == "Floor") - { - ActivateVibration(false); - } - } - } - - void OnCollisionExit(Collision collision) - { - if (collision.gameObject.tag == "Lava" || collision.gameObject.tag == "Floor") - { - ActivateVibration(false); - Animator.SetBool("IsOnLava", false); - _isInLava = false; - } - } - - void OnCollisionStay(Collision collision) - { - if (collision.gameObject.tag == "Lava") - { - _invulnerableTime += Time.deltaTime; - - if (_invulnerableTime >= MaxInvulnerableTime) - { - Debug.Log("Player " + _index + " is still standing on lava. Lose one life."); - TakeLavaDamage(); - } - - ActivateVibration(true); - } - else if (collision.gameObject.tag == "Floor") - { - ActivateVibration(false); - } - else if (_wasPushed && collision.gameObject.tag == "Walls") - { - /* - _wasPushed = false; - - Push(Vector3.Reflect(_pushedDir.normalized, collision.contacts[0].normal) * _pushedDir.magnitude);*/ - } - } - - public void Push(Vector3 force) - { - _isPushed = true; - - Debug.Log(force); - - force.y = yAngleVector; - - _rb.AddForce(force, ForceMode.Impulse); - - _pushedDir = force; - } - - private void ActivateVibration(bool activate) - { - float intensity = activate ? 0.3f : 0f; - - XInputDotNetPure.GamePad.SetVibration((XInputDotNetPure.PlayerIndex)_index, intensity, intensity); - } - - private void TakeLavaDamage() - { - NumZ += 1; - // TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds - _invulnerableTime = 0f; - } - - void Die() - { - Destroy(gameObject); - } - - void OnDestroy() - { - ActivateVibration(false); - } -} + } + + + void OnCollisionEnter(Collision collision) + { + if (collision.gameObject.tag == "Lava") + { + Debug.Log("Player " + _index + " entered lava. Lose one life."); + TakeLavaDamage(); + ActivateVibration(true); + Animator.SetBool("IsOnLava", true); + _isInLava = true; + } + else + { + // Setup for the next time the player falls on the lava + //_invulnerableTime = MaxInvulnerableTime; + + if (collision.gameObject.tag == "Floor") + { + ActivateVibration(false); + } + } + } + + void OnCollisionExit(Collision collision) + { + if (collision.gameObject.tag == "Lava" || collision.gameObject.tag == "Floor") + { + ActivateVibration(false); + Animator.SetBool("IsOnLava", false); + _isInLava = false; + } + } + + void OnCollisionStay(Collision collision) + { + if (collision.gameObject.tag == "Lava") + { + _invulnerableTime += Time.deltaTime; + + if (_invulnerableTime >= MaxInvulnerableTime) + { + Debug.Log("Player " + _index + " is still standing on lava. Lose one life."); + TakeLavaDamage(); + } + + ActivateVibration(true); + } + else if (collision.gameObject.tag == "Floor") + { + ActivateVibration(false); + } + else if (_wasPushed && collision.gameObject.tag == "Walls") + { + /* + _wasPushed = false; + + Push(Vector3.Reflect(_pushedDir.normalized, collision.contacts[0].normal) * _pushedDir.magnitude);*/ + } + } + + public void Push(Vector3 force) + { + _isPushed = true; + + Debug.Log(force); + + force.y = yAngleVector; + + _rb.AddForce(force, ForceMode.Impulse); + + _pushedDir = force; + } + + private void ActivateVibration(bool activate) + { + float intensity = activate ? 0.3f : 0f; + + XInputDotNetPure.GamePad.SetVibration((XInputDotNetPure.PlayerIndex)_index, intensity, intensity); + } + + private void TakeLavaDamage() + { + NumZ += 1; + // TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds + _invulnerableTime = 0f; + } + + void Die() + { + PlayerWinsMenu menu = (PlayerWinsMenu)MenusHandler.MenusManager.Instance.ShowMenu("PlayerWinsMenu"); + menu.SetPlayerIndex(this.Index); + + Destroy(gameObject); + } + + void OnDestroy() + { + ActivateVibration(false); + } +} diff --git a/Assets/Scripts/MomBehavior.cs b/Assets/Scripts/MomBehavior.cs index 785ca4f..180935c 100644 --- a/Assets/Scripts/MomBehavior.cs +++ b/Assets/Scripts/MomBehavior.cs @@ -116,6 +116,8 @@ public class MomBehavior : MonoBehaviour { if (child == null) continue; + Debug.Log(child.IsSleeping); + if (child.IsSleeping) { safeChildren.Add(child); diff --git a/Assets/UI/Resources/UI_P2_0.png b/Assets/UI/Resources/UI_P2_0.png index 965442d..94abb50 100644 Binary files a/Assets/UI/Resources/UI_P2_0.png and b/Assets/UI/Resources/UI_P2_0.png differ diff --git a/Assets/UI/Resources/UI_P2_0.png.meta b/Assets/UI/Resources/UI_P2_0.png.meta index 22696e3..753de3a 100644 --- a/Assets/UI/Resources/UI_P2_0.png.meta +++ b/Assets/UI/Resources/UI_P2_0.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: e06a41f1643dbac4595002871a5e5d53 -timeCreated: 1440338588 +guid: fbc5a3f21b953ea4ca66189910320d64 +timeCreated: 1440352933 licenseType: Free TextureImporter: fileIDToRecycleName: {} diff --git a/Assets/UI/Resources/UI_P2_1.png b/Assets/UI/Resources/UI_P2_1.png index 32f3874..31d2b30 100644 Binary files a/Assets/UI/Resources/UI_P2_1.png and b/Assets/UI/Resources/UI_P2_1.png differ diff --git a/Assets/UI/Resources/UI_P2_1.png.meta b/Assets/UI/Resources/UI_P2_1.png.meta index b04f7cb..76548bd 100644 --- a/Assets/UI/Resources/UI_P2_1.png.meta +++ b/Assets/UI/Resources/UI_P2_1.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 10404f9b22fe2a148ad883d271da76e0 -timeCreated: 1440338587 +guid: bc957cb3031b7e849a0265eef1496b33 +timeCreated: 1440352933 licenseType: Free TextureImporter: fileIDToRecycleName: {} diff --git a/Assets/UI/Resources/UI_P2_2.png b/Assets/UI/Resources/UI_P2_2.png index 4ff465c..bc67726 100644 Binary files a/Assets/UI/Resources/UI_P2_2.png and b/Assets/UI/Resources/UI_P2_2.png differ diff --git a/Assets/UI/Resources/UI_P2_2.png.meta b/Assets/UI/Resources/UI_P2_2.png.meta index 4887687..7fe5415 100644 --- a/Assets/UI/Resources/UI_P2_2.png.meta +++ b/Assets/UI/Resources/UI_P2_2.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 6fb3add0bf5619c4b95933df09116277 -timeCreated: 1440338588 +guid: 6c5853d409a55a040802a54246c34e0d +timeCreated: 1440352933 licenseType: Free TextureImporter: fileIDToRecycleName: {} diff --git a/Assets/UI/Resources/UI_P2_3.png b/Assets/UI/Resources/UI_P2_3.png index dc55d77..148e2af 100644 Binary files a/Assets/UI/Resources/UI_P2_3.png and b/Assets/UI/Resources/UI_P2_3.png differ diff --git a/Assets/UI/Resources/UI_P2_3.png.meta b/Assets/UI/Resources/UI_P2_3.png.meta index 518a251..32d98dc 100644 --- a/Assets/UI/Resources/UI_P2_3.png.meta +++ b/Assets/UI/Resources/UI_P2_3.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 86c7586eab4e5954f8bafeb018fd1ed0 -timeCreated: 1440338588 +guid: 0178734c2561b9a4eba97902b2338ce0 +timeCreated: 1440352932 licenseType: Free TextureImporter: fileIDToRecycleName: {} diff --git a/Assets/UI/Resources/UI_P2_4.png b/Assets/UI/Resources/UI_P2_4.png index b81a058..1420b08 100644 Binary files a/Assets/UI/Resources/UI_P2_4.png and b/Assets/UI/Resources/UI_P2_4.png differ diff --git a/Assets/UI/Resources/UI_P2_4.png.meta b/Assets/UI/Resources/UI_P2_4.png.meta index 3d49dd6..84a9e40 100644 --- a/Assets/UI/Resources/UI_P2_4.png.meta +++ b/Assets/UI/Resources/UI_P2_4.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 2ce2dd05085d5f346bf7978c08cf9c2a -timeCreated: 1440338588 +guid: 6178327a280efa2458c291a7962e815f +timeCreated: 1440352932 licenseType: Free TextureImporter: fileIDToRecycleName: {} diff --git a/Assets/UI/Resources/UI_P3_0.png b/Assets/UI/Resources/UI_P3_0.png deleted file mode 100644 index 94abb50..0000000 Binary files a/Assets/UI/Resources/UI_P3_0.png and /dev/null differ diff --git a/Assets/UI/Resources/UI_P3_0.png.meta b/Assets/UI/Resources/UI_P3_0.png.meta deleted file mode 100644 index 753de3a..0000000 --- a/Assets/UI/Resources/UI_P3_0.png.meta +++ /dev/null @@ -1,55 +0,0 @@ -fileFormatVersion: 2 -guid: fbc5a3f21b953ea4ca66189910320d64 -timeCreated: 1440352933 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 8 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - filterMode: -1 - aniso: 16 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 8 - buildTargetSettings: [] - spriteSheet: - sprites: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UI/Resources/UI_P3_1.png b/Assets/UI/Resources/UI_P3_1.png deleted file mode 100644 index 31d2b30..0000000 Binary files a/Assets/UI/Resources/UI_P3_1.png and /dev/null differ diff --git a/Assets/UI/Resources/UI_P3_1.png.meta b/Assets/UI/Resources/UI_P3_1.png.meta deleted file mode 100644 index 76548bd..0000000 --- a/Assets/UI/Resources/UI_P3_1.png.meta +++ /dev/null @@ -1,55 +0,0 @@ -fileFormatVersion: 2 -guid: bc957cb3031b7e849a0265eef1496b33 -timeCreated: 1440352933 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 8 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - filterMode: -1 - aniso: 16 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 8 - buildTargetSettings: [] - spriteSheet: - sprites: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UI/Resources/UI_P3_2.png b/Assets/UI/Resources/UI_P3_2.png deleted file mode 100644 index bc67726..0000000 Binary files a/Assets/UI/Resources/UI_P3_2.png and /dev/null differ diff --git a/Assets/UI/Resources/UI_P3_2.png.meta b/Assets/UI/Resources/UI_P3_2.png.meta deleted file mode 100644 index 7fe5415..0000000 --- a/Assets/UI/Resources/UI_P3_2.png.meta +++ /dev/null @@ -1,55 +0,0 @@ -fileFormatVersion: 2 -guid: 6c5853d409a55a040802a54246c34e0d -timeCreated: 1440352933 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 8 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - filterMode: -1 - aniso: 16 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 8 - buildTargetSettings: [] - spriteSheet: - sprites: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UI/Resources/UI_P3_3.png b/Assets/UI/Resources/UI_P3_3.png deleted file mode 100644 index 148e2af..0000000 Binary files a/Assets/UI/Resources/UI_P3_3.png and /dev/null differ diff --git a/Assets/UI/Resources/UI_P3_3.png.meta b/Assets/UI/Resources/UI_P3_3.png.meta deleted file mode 100644 index 32d98dc..0000000 --- a/Assets/UI/Resources/UI_P3_3.png.meta +++ /dev/null @@ -1,55 +0,0 @@ -fileFormatVersion: 2 -guid: 0178734c2561b9a4eba97902b2338ce0 -timeCreated: 1440352932 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 8 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - filterMode: -1 - aniso: 16 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 8 - buildTargetSettings: [] - spriteSheet: - sprites: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UI/Resources/UI_P3_4.png b/Assets/UI/Resources/UI_P3_4.png deleted file mode 100644 index 1420b08..0000000 Binary files a/Assets/UI/Resources/UI_P3_4.png and /dev/null differ diff --git a/Assets/UI/Resources/UI_P3_4.png.meta b/Assets/UI/Resources/UI_P3_4.png.meta deleted file mode 100644 index 84a9e40..0000000 --- a/Assets/UI/Resources/UI_P3_4.png.meta +++ /dev/null @@ -1,55 +0,0 @@ -fileFormatVersion: 2 -guid: 6178327a280efa2458c291a7962e815f -timeCreated: 1440352932 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 1 - linearTexture: 0 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: .25 - normalMapFilter: 0 - isReadable: 0 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 8 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -1 - maxTextureSize: 2048 - textureSettings: - filterMode: -1 - aniso: 16 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 8 - buildTargetSettings: [] - spriteSheet: - sprites: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 802c8ce..8c353d8 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.0.2f1 +m_EditorVersion: 5.1.2f1 m_StandardAssetsVersion: 0