From 9d82191cbce91918c5b445e87dcc03b06efe9ff0 Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sun, 23 Aug 2015 13:02:34 -0400 Subject: [PATCH 1/5] Character animation --- Assets/Prefabs/Child.prefab | 10 +++--- Assets/Prefabs/Kid_AnimControl.controller | 6 ++-- Assets/Scenes/PatScene.unity | 40 +++-------------------- Assets/Scripts/Child.cs | 6 ++++ 4 files changed, 18 insertions(+), 44 deletions(-) diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index 9c7e225..3691cf5 100644 --- a/Assets/Prefabs/Child.prefab +++ b/Assets/Prefabs/Child.prefab @@ -920,7 +920,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 190616} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.3900001, y: .970000029, z: .25} + m_LocalPosition: {x: -2.02999997, y: .97299999, z: 2.27999997} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 421634} @@ -1082,7 +1082,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e6ffb35a11ff1f545ac22f7ea752cffb, type: 3} m_Name: m_EditorClassIdentifier: - PlayerNumber: 0 + PlayerNumber: 1 --- !u!114 &11474836 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1117,7 +1117,7 @@ SphereCollider: m_IsTrigger: 1 m_Enabled: 1 serializedVersion: 2 - m_Radius: .75 + m_Radius: .519999981 m_Center: {x: 0, y: 0, z: 0} --- !u!136 &13685066 CapsuleCollider: @@ -1128,8 +1128,8 @@ CapsuleCollider: m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - m_Radius: .5 - m_Height: 1 + m_Radius: .209999993 + m_Height: 1.00999999 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} --- !u!137 &13704276 diff --git a/Assets/Prefabs/Kid_AnimControl.controller b/Assets/Prefabs/Kid_AnimControl.controller index 8a1e2e5..fe32a51 100644 --- a/Assets/Prefabs/Kid_AnimControl.controller +++ b/Assets/Prefabs/Kid_AnimControl.controller @@ -14,7 +14,7 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} - - m_Name: start_attack + - m_Name: StartAttack m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 @@ -59,7 +59,7 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 - m_ConditionEvent: start_attack + m_ConditionEvent: StartAttack m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 110284670} @@ -434,7 +434,7 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 - m_ConditionEvent: start_attack + m_ConditionEvent: StartAttack m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 110284670} diff --git a/Assets/Scenes/PatScene.unity b/Assets/Scenes/PatScene.unity index 633ce1a..97eea8b 100644 --- a/Assets/Scenes/PatScene.unity +++ b/Assets/Scenes/PatScene.unity @@ -598,38 +598,6 @@ Prefab: propertyPath: Mom value: objectReference: {fileID: 1257411050} - - target: {fileID: 11446734, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: PlayerNumber - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: hitPushBackForce - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 13685066, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: m_Material - value: - objectReference: {fileID: 0} - - target: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: Speed - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 5480620, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: m_AngularDrag - value: .0500000007 - objectReference: {fileID: 0} - - target: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: yAngleVector - value: 3 - objectReference: {fileID: 0} - - target: {fileID: 5480620, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: m_Mass - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: JumpForce - value: 200 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} m_IsPrefabParent: 0 @@ -1097,10 +1065,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 @@ -2554,6 +2518,10 @@ Prefab: propertyPath: Mom value: objectReference: {fileID: 1257411050} + - 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 6d739c0..d458d8b 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -24,6 +24,7 @@ public class Child : MonoBehaviour private float _invulnerableTime; private Bed _currentBed; public Transform target; + private bool _isInLava; private int _index; private bool _isPushed = false; @@ -186,6 +187,7 @@ public class Child : MonoBehaviour } internal void Throw() { + if (_isInLava) return; if (pillow != null) { @@ -205,6 +207,8 @@ public class Child : MonoBehaviour pillow.IsOwned = false; pillow = null; + + Animator.SetTrigger("StartAttack"); } } @@ -217,6 +221,7 @@ public class Child : MonoBehaviour TakeLavaDamage(); ActivateVibration(true); Animator.SetBool("IsOnLava", true); + _isInLava = true; } else { @@ -236,6 +241,7 @@ public class Child : MonoBehaviour { ActivateVibration(false); Animator.SetBool("IsOnLava", false); + _isInLava = false; } } From f0e46a94296825b453512a7194cfff5bb9adec1d Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sun, 23 Aug 2015 13:11:34 -0400 Subject: [PATCH 2/5] New pillow texture --- Assets/Art/Materials/Pillow_Uv.mat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Art/Materials/Pillow_Uv.mat b/Assets/Art/Materials/Pillow_Uv.mat index ca148f8..a8e5273 100644 --- a/Assets/Art/Materials/Pillow_Uv.mat +++ b/Assets/Art/Materials/Pillow_Uv.mat @@ -19,7 +19,7 @@ Material: first: name: _MainTex second: - m_Texture: {fileID: 0} + m_Texture: {fileID: 2800000, guid: 48ae88018d91f93498ab72c5e26bf101, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} data: From e4ee5509f6115bd7302df48323032162f63bd0f9 Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sun, 23 Aug 2015 13:20:22 -0400 Subject: [PATCH 3/5] Commit for pull --- Assets/Scenes/PatScene.unity | 5 +++++ Assets/Scripts/Child.cs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Assets/Scenes/PatScene.unity b/Assets/Scenes/PatScene.unity index 97eea8b..24f7705 100644 --- a/Assets/Scenes/PatScene.unity +++ b/Assets/Scenes/PatScene.unity @@ -1014,6 +1014,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: PlayerCount: 4 + mom: {fileID: 1257411050} --- !u!4 &945259370 Transform: m_ObjectHideFlags: 0 @@ -2522,6 +2523,10 @@ Prefab: propertyPath: PlayerNumber value: 0 objectReference: {fileID: 0} + - target: {fileID: 134552, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} + propertyPath: m_IsActive + value: 1 + 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 dd1d4a9..98cd135 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -15,6 +15,7 @@ public class Child : MonoBehaviour public Pillow pillow; public MomBehavior Mom; public Animator Animator; + public GameObject AnimationPillow; private Rigidbody _rb; private bool _isGrounded = false; @@ -48,6 +49,7 @@ public class Child : MonoBehaviour void Awake() { _rb = GetComponent(); + AnimationPillow.SetActive(false); } void Update() From 5bb2c0629756ba9d858197ab1f0205675252b912 Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Sun, 23 Aug 2015 13:28:57 -0400 Subject: [PATCH 4/5] Anchor modifications --- Assets/Prefabs/Child.prefab | 4 +- Assets/Scenes/Gameplay.unity | 153 ++++++++++++- Assets/Scripts/MomBehavior.cs | 310 +++++++++++++------------- ProjectSettings/ProjectSettings.asset | 20 +- 4 files changed, 319 insertions(+), 168 deletions(-) diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index 3691cf5..c8330af 100644 --- a/Assets/Prefabs/Child.prefab +++ b/Assets/Prefabs/Child.prefab @@ -920,7 +920,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 190616} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.02999997, y: .97299999, z: 2.27999997} + m_LocalPosition: {x: -2.3900001, y: .970000029, z: .25} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 421634} @@ -1069,7 +1069,9 @@ MonoBehaviour: GroundCheck: {fileID: 100272} pillow: {fileID: 0} Mom: {fileID: 0} + Avatar: {fileID: 0} Animator: {fileID: 9580008} + AnimationPillow: {fileID: 134552} target: {fileID: 0} --- !u!114 &11446734 MonoBehaviour: diff --git a/Assets/Scenes/Gameplay.unity b/Assets/Scenes/Gameplay.unity index de37735..9dfd389 100644 --- a/Assets/Scenes/Gameplay.unity +++ b/Assets/Scenes/Gameplay.unity @@ -620,6 +620,7 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 --- !u!4 &573037243 Transform: m_ObjectHideFlags: 0 @@ -726,6 +727,146 @@ 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} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: dec23153e975cb94db47e642092ad58e, type: 2} m_IsPrefabParent: 0 @@ -2446,14 +2587,18 @@ Prefab: propertyPath: Mom value: objectReference: {fileID: 673576180} - - target: {fileID: 190616, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} - propertyPath: m_Name - value: Child 1 - objectReference: {fileID: 0} - target: {fileID: 11430644, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} propertyPath: Avatar value: objectReference: {fileID: 673576181} + - target: {fileID: 190616, guid: 6dd661a967968c64dbae75c01fac6a09, type: 2} + 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/MomBehavior.cs b/Assets/Scripts/MomBehavior.cs index 231b88c..785ca4f 100644 --- a/Assets/Scripts/MomBehavior.cs +++ b/Assets/Scripts/MomBehavior.cs @@ -1,157 +1,157 @@ -using UnityEngine; -using System.Collections; -using UnityEngine.UI; -using System.Collections.Generic; -using System; -using MenusHandler; -using InputHandler; - -public class MomBehavior : MonoBehaviour -{ - public Action OnEnterRoom; - public Action OnLeaveRoom; - - public Text WarningText; - public float MinTriggerTime = 60f; - public float MaxTriggerTime = 90f; - public float WarningHeadsupTime = 5f; - public float MotherStayTime = 2f; - public Door RoomDoor; - - public Child[] Children; - - public enum State { Away, Warning, InRoom } - - private State _currentState; - - private float _elapsedTime = 0f; - - private float _nextTriggerTime; - - private bool _gameOver = false; - - public bool IsInRoom - { - get { return _currentState == State.InRoom; } - } - - void Awake() - { - _nextTriggerTime = GetNextTriggerTime(); - } - - void Update() - { - if (_gameOver) return; - - // When the mom hasn't been triggered for a while, it can appear anytime between 2 borders - - _elapsedTime += Time.deltaTime; - - switch (_currentState) - { - case State.Away: - if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime) - { - SetState(State.Warning); - } - break; - case State.Warning: - if (_elapsedTime >= _nextTriggerTime) - { - SetState(State.InRoom); - } - break; - case State.InRoom: - if (_elapsedTime >= MotherStayTime) - { - SetState(State.Away); - } - - CheckIfSleeping(); - break; - } - } - - private void SetState(State newState) - { - switch (newState) - { - case State.Away: - RoomDoor.Close(OnLeaveRoom); - _elapsedTime = 0f; - break; - case State.Warning: - // Temporary - WarningText.gameObject.SetActive(true); - - RoomDoor.Open(); - break; - case State.InRoom: - // Temporary - WarningText.gameObject.SetActive(false); - _nextTriggerTime = GetNextTriggerTime(); - - _elapsedTime = 0f; - - if (OnEnterRoom != null) - { - OnEnterRoom(); - } - break; - } - - _currentState = newState; - } - - public State GetState(){ - return _currentState; - } - - private void CheckIfSleeping() - { - List safeChildren = new List(); - - foreach (Child child in Children) - { - if (child == null) continue; - - if (child.IsSleeping) - { - safeChildren.Add(child); - } - else - { - Debug.Log("Player " + child.Index + " has been spotted by mom."); - +using UnityEngine; +using System.Collections; +using UnityEngine.UI; +using System.Collections.Generic; +using System; +using MenusHandler; +using InputHandler; + +public class MomBehavior : MonoBehaviour +{ + public Action OnEnterRoom; + public Action OnLeaveRoom; + + public Text WarningText; + public float MinTriggerTime = 60f; + public float MaxTriggerTime = 90f; + public float WarningHeadsupTime = 5f; + public float MotherStayTime = 2f; + public Door RoomDoor; + + public Child[] Children; + + public enum State { Away, Warning, InRoom } + + private State _currentState; + + private float _elapsedTime = 0f; + + private float _nextTriggerTime; + + private bool _gameOver = false; + + public bool IsInRoom + { + get { return _currentState == State.InRoom; } + } + + void Awake() + { + _nextTriggerTime = GetNextTriggerTime(); + } + + void Update() + { + if (_gameOver) return; + + // When the mom hasn't been triggered for a while, it can appear anytime between 2 borders + + _elapsedTime += Time.deltaTime; + + switch (_currentState) + { + case State.Away: + if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime) + { + SetState(State.Warning); + } + break; + case State.Warning: + if (_elapsedTime >= _nextTriggerTime) + { + SetState(State.InRoom); + } + break; + case State.InRoom: + if (_elapsedTime >= MotherStayTime) + { + SetState(State.Away); + } + + CheckIfSleeping(); + break; + } + } + + private void SetState(State newState) + { + switch (newState) + { + case State.Away: + RoomDoor.Close(OnLeaveRoom); + _elapsedTime = 0f; + break; + case State.Warning: + // Temporary + WarningText.gameObject.SetActive(true); + + RoomDoor.Open(); + break; + case State.InRoom: + // Temporary + WarningText.gameObject.SetActive(false); + _nextTriggerTime = GetNextTriggerTime(); + + _elapsedTime = 0f; + + if (OnEnterRoom != null) + { + OnEnterRoom(); + } + break; + } + + _currentState = newState; + } + + public State GetState(){ + return _currentState; + } + + private void CheckIfSleeping() + { + List safeChildren = new List(); + + foreach (Child child in Children) + { + if (child == null) continue; + + if (child.IsSleeping) + { + safeChildren.Add(child); + } + else + { + Debug.Log("Player " + child.Index + " has been spotted by mom."); + // TODO: Visual animation that the player lost (lasso?) - child.NumZ = 4; - Destroy(child.gameObject); - } - } - - if (safeChildren.Count == 0) - { - Debug.Log("Mom wins!"); - - MenusManager.Instance.ShowMenu("MomWinsMenu"); - - _gameOver = true; - } - else if (safeChildren.Count == 1) - { - Debug.Log("Player " + safeChildren[0].Index + " wins!"); - - PlayerWinsMenu menu = (PlayerWinsMenu)MenusManager.Instance.ShowMenu("PlayerWinsMenu"); - menu.SetPlayerIndex(safeChildren[0].Index); - - _gameOver = true; - } - } - - private float GetNextTriggerTime() - { - return UnityEngine.Random.Range(MinTriggerTime, MaxTriggerTime); - } -} + child.NumZ = 4; + Destroy(child.gameObject); + } + } + + if (safeChildren.Count == 0) + { + Debug.Log("Mom wins!"); + + MenusManager.Instance.ShowMenu("MomWinsMenu"); + + _gameOver = true; + } + else if (safeChildren.Count == 1) + { + Debug.Log("Player " + safeChildren[0].Index + " wins!"); + + PlayerWinsMenu menu = (PlayerWinsMenu)MenusManager.Instance.ShowMenu("PlayerWinsMenu"); + menu.SetPlayerIndex(safeChildren[0].Index); + + _gameOver = true; + } + } + + private float GetNextTriggerTime() + { + return UnityEngine.Random.Range(MinTriggerTime, MaxTriggerTime); + } +} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 77d8ed2..bcff247 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,17 +3,14 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 6 + serializedVersion: 7 AndroidProfiler: 0 defaultScreenOrientation: 4 targetDevice: 2 - targetGlesGraphics: -1 - targetIOSGraphics: -1 targetResolution: 0 accelerometerFrequency: 60 companyName: DefaultCompany productName: PillowUnity - cloudProjectId: defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_ShowUnitySplashScreen: 1 @@ -26,7 +23,6 @@ PlayerSettings: m_ActiveColorSpace: 0 m_MTRendering: 1 m_MobileMTRendering: 0 - m_UseDX11: 1 m_Stereoscopic3D: 0 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 @@ -81,6 +77,7 @@ PlayerSettings: metroEnableIndependentInputSource: 0 metroEnableLowLatencyPresentationAPI: 0 xboxOneDisableKinectGpuReservation: 0 + virtualRealitySupported: 0 productGUID: f74b42ae0c00e944a95d85e94fc9366e AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 9 @@ -123,6 +120,7 @@ PlayerSettings: iOSLaunchScreenCustomXibPath: AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: AndroidTVCompatibility: 1 @@ -136,6 +134,7 @@ PlayerSettings: resolutionDialogBanner: {fileID: 0} m_BuildTargetIcons: [] m_BuildTargetBatching: [] + m_BuildTargetGraphicsAPIs: [] webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} actionOnDotNetUnhandledException: 1 @@ -197,6 +196,7 @@ PlayerSettings: ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 ps4ApplicationParam4: 0 + ps4GarlicHeapSize: 2048 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 ps4pnPresence: 1 @@ -339,8 +339,7 @@ PlayerSettings: blackberrySquareSplashScreen: {fileID: 0} tizenProductDescription: tizenProductURL: - tizenCertificatePath: - tizenCertificatePassword: + tizenSigningProfileName: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 stvDeviceAddress: @@ -402,4 +401,9 @@ PlayerSettings: WebGL::emscriptenArgs: WebGL::template: APPLICATION:Default additionalIl2CppArgs::additionalIl2CppArgs: - firstStreamedLevelWithResources: 0 + firstStreamedSceneWithResources: 0 + cloudProjectId: + projectId: + projectName: + organizationId: + cloudEnabled: 0 From 989342197c8a04a536d7f4e76c34712556413d6a Mon Sep 17 00:00:00 2001 From: jparent Date: Sun, 23 Aug 2015 13:46:54 -0400 Subject: [PATCH 5/5] fix Throwing pillow to not snap but still auto aim Right joystick still rotates the player, but no longer snaps to a player. Also, the auto-targeting is now used exlusively inside the Child's Throw method. When throwing, it checks if there is a player in the direction the player is pointing. If so, then the pillow is going this way, else it goes in the Child's forward position. --- Assets/Prefabs/Child.prefab | 5 ++--- Assets/Scripts/AutoTarget.cs | 2 +- Assets/Scripts/Child.cs | 16 +++++++++------- Assets/Scripts/ChildController.cs | 14 +++----------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Assets/Prefabs/Child.prefab b/Assets/Prefabs/Child.prefab index 9c7e225..ca14407 100644 --- a/Assets/Prefabs/Child.prefab +++ b/Assets/Prefabs/Child.prefab @@ -1070,7 +1070,6 @@ MonoBehaviour: pillow: {fileID: 0} Mom: {fileID: 0} Animator: {fileID: 9580008} - target: {fileID: 0} --- !u!114 &11446734 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1094,7 +1093,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 567fe96dcacb08f4ab716a98ce99fc88, type: 3} m_Name: m_EditorClassIdentifier: - minAngleRange: 10 + minAngleRange: 30 --- !u!135 &13545904 SphereCollider: m_ObjectHideFlags: 1 @@ -1248,7 +1247,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 0} propertyPath: minAngleRange - value: 10 + value: 30 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 0} diff --git a/Assets/Scripts/AutoTarget.cs b/Assets/Scripts/AutoTarget.cs index 178e3ad..bfebfc6 100644 --- a/Assets/Scripts/AutoTarget.cs +++ b/Assets/Scripts/AutoTarget.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; public class AutoTarget : MonoBehaviour { private List targets; - public float minAngleRange = 20f; + public float minAngleRange = 30f; // Use this for initialization void Start () diff --git a/Assets/Scripts/Child.cs b/Assets/Scripts/Child.cs index 42d3ed5..01d454f 100644 --- a/Assets/Scripts/Child.cs +++ b/Assets/Scripts/Child.cs @@ -23,7 +23,6 @@ public class Child : MonoBehaviour private bool _isSleeping; private float _invulnerableTime; private Bed _currentBed; - public Transform target; private int _index; private bool _isPushed = false; @@ -32,6 +31,8 @@ public class Child : MonoBehaviour private float _stunTime; + private AutoTarget _autoTarget; + public int Index { get { return _index; } @@ -47,6 +48,7 @@ public class Child : MonoBehaviour void Awake() { _rb = GetComponent(); + _autoTarget = GetComponent(); } void Update() @@ -54,11 +56,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 @@ -185,12 +183,14 @@ public class Child : MonoBehaviour return colliders.Length > 0 ? colliders[0].GetComponent() : null; } - internal void Throw() { + public void Throw() { if (pillow != null) { Vector3 direction; + Transform target = _autoTarget.GetTarget(transform.forward); + if (target != null) { direction = target.transform.position - pillow.transform.position; } @@ -205,6 +205,8 @@ public class Child : MonoBehaviour pillow.IsOwned = false; pillow = null; + + target = null; } } diff --git a/Assets/Scripts/ChildController.cs b/Assets/Scripts/ChildController.cs index 2f33e1d..a63059e 100644 --- a/Assets/Scripts/ChildController.cs +++ b/Assets/Scripts/ChildController.cs @@ -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) {