corrigé bug dashing et angle négatif (trouvais pas l'index des plateaux)

This commit is contained in:
Jean-Sébastien Gervais 2016-04-08 18:34:01 -04:00
parent 119ae969c3
commit 4d6094b40f
4 changed files with 16 additions and 9 deletions

View File

@ -51,8 +51,6 @@ public class AsteroidSpawner : TimerFunctionsClass
} }
//Cooldown untill next random spawn //Cooldown untill next random spawn
SetTimer(NextSpawnTime, SpawnAsteroidEvent); SetTimer(NextSpawnTime, SpawnAsteroidEvent);
StartTimer(); StartTimer();

View File

@ -13,7 +13,8 @@ public class Astronaut : MonoBehaviour {
public GameObject SpriteDash; public GameObject SpriteDash;
public float Width; public float Width;
public float DashTime = 0.4f; //Temps de l'animation et rate limiting
private float lastDashTime = 0f;
public float StepTime; public float StepTime;
public float JumpSpeed; public float JumpSpeed;
public float Gravity; public float Gravity;
@ -185,7 +186,7 @@ public class Astronaut : MonoBehaviour {
float movement = PlanetUtilities.GetDisplacementAngle(Speed * -x, height) * Time.deltaTime; float movement = PlanetUtilities.GetDisplacementAngle(Speed * -x, height) * Time.deltaTime;
//Debug.Log("Moving! - " + height); //Debug.Log("Moving! - " + height);
//Debug.Log("Daaa - " + movement); //Debug.Log("Daaa - " + movement);
float newTheta = theta + movement; float newTheta = (360 + theta + movement) % 360; // angle positif
float newHeight = GetGroundRadius(newTheta); float newHeight = GetGroundRadius(newTheta);
if (newHeight > height) if (newHeight > height)
@ -210,9 +211,14 @@ public class Astronaut : MonoBehaviour {
public void Dash() 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); planet.PushWedge(this.theta);
} }

View File

@ -51,8 +51,11 @@ public class AstronautController : MonoBehaviour {
if (input.Ranges.ContainsKey("Dash")) if (input.Ranges.ContainsKey("Dash"))
{ {
if(input.Ranges["Dash"] > 0.8f) if (input.Ranges["Dash"] > 0.8f)
_astronaut.Dash(); {
_astronaut.Dash();
}
} }
} }

View File

@ -213,7 +213,7 @@ public class PlanetManager : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public Wedge GetWedgeFromTheta(float thetaPlayerX) public Wedge GetWedgeFromTheta(float thetaPlayerX)
{ {
return wedges[GetWedgeIndex(thetaPlayerX)]; return wedges[GetWedgeIndex(thetaPlayerX % 360)];
} }
/// <summary> /// <summary>