diff --git a/Assets/Prefabs/Astronaut.prefab b/Assets/Prefabs/Astronaut.prefab index 6d51882..110618e 100644 --- a/Assets/Prefabs/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut.prefab @@ -160,7 +160,8 @@ MonoBehaviour: aspi: {fileID: 0} WalkAnimSpeed: 0 WalkAnimAngle: 0 - EjectSpinSpeed: 0 + EjectSpinSpeed: 80 + DustParticlesEmitter: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2} --- !u!114 &11494368 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/P_DashImpact.prefab b/Assets/Prefabs/P_DashImpact.prefab index eea93a7..ee3dc2e 100644 --- a/Assets/Prefabs/P_DashImpact.prefab +++ b/Assets/Prefabs/P_DashImpact.prefab @@ -74,7 +74,7 @@ ParticleSystem: minMaxState: 0 speed: 1 randomSeed: 0 - looping: 1 + looping: 0 prewarm: 0 playOnAwake: 1 moveWithTransform: 1 diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index f51e846..f087878 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -42,14 +42,19 @@ public class Astronaut : MonoBehaviour { if (oldState == AstronautState.Dashing) { - SpriteWalk.gameObject.SetActive(false); - SpriteDash.gameObject.SetActive(true); + _astronautAnimator.Land(); + //SpriteWalk.gameObject.SetActive(false); + //SpriteDash.gameObject.SetActive(true); } - else + //else if (_state == AstronautState.Jumping) + //{ + // _astronautAnimator.Jump(); + //} + /*else { SpriteWalk.gameObject.SetActive(true); SpriteDash.gameObject.SetActive(false); - } + }*/ /*if (_state == AstronautState.Walking) { @@ -78,7 +83,7 @@ public class Astronaut : MonoBehaviour { } // Use this for initialization - void Start() + protected void Start() { _astronautAnimator = GetComponent(); _astronautAnimator.aspi = this; @@ -242,20 +247,23 @@ public class Astronaut : MonoBehaviour { { Debug.Log("Jump!"); - if (State >= AstronautState.Ejecting) - return; - - _astronautAnimator.Jump(); + if (State == AstronautState.Jumping) { Dash(); - State=AstronautState.Dashing; //TODO relacher l'état Dashing + //State=AstronautState.Dashing; //TODO relacher l'état Dashing return; } + else if (State >= AstronautState.Dashing) + return; + else if (State >= AstronautState.Ejecting) + return; - if (!grounded) return; + _astronautAnimator.Jump(); // deja dans le property get/set + + if (!grounded) return; vSpeed = JumpSpeed; grounded = false; State = AstronautState.Jumping; @@ -270,10 +278,11 @@ public class Astronaut : MonoBehaviour { if (State >= AstronautState.Ejecting) return; + lastDashTime = Time.time; - planet.PushWedge(this.theta); - - //State = AstronautState.Dashing; + planet.PushWedge(this.theta); //TODO devrait se faire juste avant d'être groundé + State = AstronautState.Dashing; + _astronautAnimator.Dash(); //vSpeed = -DashSpeed; } @@ -281,6 +290,7 @@ public class Astronaut : MonoBehaviour { { State = AstronautState.Ejecting; vSpeed = EjectSpeed; + _astronautAnimator.Eject(); grounded = false; } diff --git a/Assets/Scripts/AstronautAnimator.cs b/Assets/Scripts/AstronautAnimator.cs index 4699bd6..c2dc410 100644 --- a/Assets/Scripts/AstronautAnimator.cs +++ b/Assets/Scripts/AstronautAnimator.cs @@ -9,17 +9,24 @@ public class AstronautAnimator : MonoBehaviour { public float WalkAnimAngle; public float EjectSpinSpeed; - // Use this for initialization - void Start () { + public GameObject DustParticlesEmitter; + // Use this for initialization + protected void Start () { } // Update is called once per frame - void Update () { + protected void Update () { } public void Jump() + { + aspi.SpriteWalk.gameObject.SetActive(true); + aspi.SpriteDash.gameObject.SetActive(false); + } + + public void Dash() { aspi.SpriteWalk.gameObject.SetActive(false); aspi.SpriteDash.gameObject.SetActive(true); @@ -27,6 +34,7 @@ public class AstronautAnimator : MonoBehaviour { public void Land() { + aspi.SpriteWalk.gameObject.SetActive(true); aspi.SpriteDash.gameObject.SetActive(false); } @@ -72,4 +80,12 @@ public class AstronautAnimator : MonoBehaviour { } yield return null; } + + public void EmitDustParticules() + { + if (DustParticlesEmitter) + { + var emitter = (GameObject)Instantiate(DustParticlesEmitter, this.gameObject.transform.position, Quaternion.identity); + } + } } diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index 157fd4d..c67181e 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -85,25 +85,6 @@ NavMeshSettings: cellSize: 0.16666667 manualCellSize: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &431637404 stripped -GameObject: - m_PrefabParentObject: {fileID: 170392, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - m_PrefabInternal: {fileID: 1660116367} ---- !u!114 &431637411 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 431637404} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 77462b2431858f84b9bc2d055c2f4d45, type: 3} - m_Name: - m_EditorClassIdentifier: - aspi: {fileID: 0} - WalkAnimSpeed: 0 - WalkAnimAngle: 0 - EjectSpinSpeed: 0 --- !u!114 &1027139440 stripped MonoBehaviour: m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, @@ -157,11 +138,6 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 158e745881137e04ca2086294f44d74c, type: 2} m_IsPrefabParent: 0 ---- !u!212 &1106066633 stripped -SpriteRenderer: - m_PrefabParentObject: {fileID: 21220066, guid: acd71c7b2f995984d9033c9dc4e257dc, - type: 2} - m_PrefabInternal: {fileID: 1660116367} --- !u!1001 &1223268487 Prefab: m_ObjectHideFlags: 0 @@ -243,6 +219,10 @@ Prefab: propertyPath: m_RootOrder value: 2 objectReference: {fileID: 0} + - target: {fileID: 11401034, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: gaugeMax + value: 100 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 198e988adacced646a19f757f6237ae1, type: 2} m_IsPrefabParent: 0 @@ -293,41 +273,13 @@ Prefab: propertyPath: m_Name value: Astronaut_1 objectReference: {fileID: 0} - - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_AngularDrag - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_IsKinematic - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_UseGravity - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_Mass - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_Center.y - value: 1.31 - objectReference: {fileID: 0} - - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_Height - value: 1.59 - objectReference: {fileID: 0} - - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_Radius - value: 0.76 - objectReference: {fileID: 0} - - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: SpriteWalk + - target: {fileID: 11491252, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: DustParticlesEmitter value: - objectReference: {fileID: 1106066633} - - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: EjectSpeed - value: 10 + objectReference: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2} + - target: {fileID: 11491252, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: EjectSpinSpeed + value: -50 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}