From 4d6094b40f5ba014ec8ec9c3ef351e51a2e2dfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Fri, 8 Apr 2016 18:34:01 -0400 Subject: [PATCH] =?UTF-8?q?corrig=C3=A9=20bug=20dashing=20et=20angle=20n?= =?UTF-8?q?=C3=A9gatif=20(trouvais=20pas=20l'index=20des=20plateaux)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/AsteroidSpawner.cs | 2 -- Assets/Scripts/Astronaut.cs | 14 ++++++++++---- Assets/Scripts/AstronautController.cs | 7 +++++-- Assets/Scripts/PlanetManager.cs | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/AsteroidSpawner.cs b/Assets/Scripts/AsteroidSpawner.cs index f837b34..f915a1e 100644 --- a/Assets/Scripts/AsteroidSpawner.cs +++ b/Assets/Scripts/AsteroidSpawner.cs @@ -51,8 +51,6 @@ public class AsteroidSpawner : TimerFunctionsClass } - - //Cooldown untill next random spawn SetTimer(NextSpawnTime, SpawnAsteroidEvent); StartTimer(); diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 0beaf1b..e37c886 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -13,7 +13,8 @@ public class Astronaut : MonoBehaviour { public GameObject SpriteDash; public float Width; - + public float DashTime = 0.4f; //Temps de l'animation et rate limiting + private float lastDashTime = 0f; public float StepTime; public float JumpSpeed; public float Gravity; @@ -185,7 +186,7 @@ public class Astronaut : MonoBehaviour { float movement = PlanetUtilities.GetDisplacementAngle(Speed * -x, height) * Time.deltaTime; //Debug.Log("Moving! - " + height); //Debug.Log("Daaa - " + movement); - float newTheta = theta + movement; + float newTheta = (360 + theta + movement) % 360; // angle positif float newHeight = GetGroundRadius(newTheta); if (newHeight > height) @@ -210,9 +211,14 @@ public class Astronaut : MonoBehaviour { public void Dash() { - if (_state >= AstronautState.Ejecting) - return; + + if (Time.time < DashTime + lastDashTime) + return; + + if (_state >= AstronautState.Ejecting) + return; + lastDashTime = Time.time; planet.PushWedge(this.theta); } diff --git a/Assets/Scripts/AstronautController.cs b/Assets/Scripts/AstronautController.cs index 0492100..ecd56b0 100644 --- a/Assets/Scripts/AstronautController.cs +++ b/Assets/Scripts/AstronautController.cs @@ -51,8 +51,11 @@ public class AstronautController : MonoBehaviour { if (input.Ranges.ContainsKey("Dash")) { - if(input.Ranges["Dash"] > 0.8f) - _astronaut.Dash(); + if (input.Ranges["Dash"] > 0.8f) + { + _astronaut.Dash(); + } + } } diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 9bf9861..ad5f38e 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -213,7 +213,7 @@ public class PlanetManager : MonoBehaviour /// public Wedge GetWedgeFromTheta(float thetaPlayerX) { - return wedges[GetWedgeIndex(thetaPlayerX)]; + return wedges[GetWedgeIndex(thetaPlayerX % 360)]; } ///