Replaced magic numbers with constants
This commit is contained in:
parent
9160a0092a
commit
643460f392
|
@ -14,6 +14,9 @@ namespace Player
|
||||||
private const float MaxSpeed = 500.0f;
|
private const float MaxSpeed = 500.0f;
|
||||||
private const float DefaultAirSpeed = 300.0f;
|
private const float DefaultAirSpeed = 300.0f;
|
||||||
private const float GravityScale = 5.0f;
|
private const float GravityScale = 5.0f;
|
||||||
|
private const float AccelerationScale = 40.0f;
|
||||||
|
private const float DecelerationScale = 60.0f;
|
||||||
|
private const float RespawnLimit = -60.0f;
|
||||||
|
|
||||||
private const float FallMultiplier = 4.0f;
|
private const float FallMultiplier = 4.0f;
|
||||||
private const float LowJumpMultiplier = 4.0f;
|
private const float LowJumpMultiplier = 4.0f;
|
||||||
|
@ -110,7 +113,7 @@ namespace Player
|
||||||
|
|
||||||
private void RespawnCheck()
|
private void RespawnCheck()
|
||||||
{
|
{
|
||||||
if (gameObject.transform.position.y < -100)
|
if (gameObject.transform.position.y < RespawnLimit)
|
||||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,14 +167,14 @@ namespace Player
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_isOnAir)
|
if (!_isOnAir)
|
||||||
BaseSpeed += 40;
|
BaseSpeed += AccelerationScale;
|
||||||
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * _xAxisValue * Time.fixedDeltaTime,
|
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * _xAxisValue * Time.fixedDeltaTime,
|
||||||
_playerRigidbody2D.velocity.y);
|
_playerRigidbody2D.velocity.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DecelerationAfterMoving()
|
private void DecelerationAfterMoving()
|
||||||
{
|
{
|
||||||
BaseSpeed -= 80;
|
BaseSpeed -= DecelerationScale;
|
||||||
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * (int)_orientation * Time.fixedDeltaTime,
|
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * (int)_orientation * Time.fixedDeltaTime,
|
||||||
_playerRigidbody2D.velocity.y);
|
_playerRigidbody2D.velocity.y);
|
||||||
if (BaseSpeed == 0)
|
if (BaseSpeed == 0)
|
||||||
|
|
Loading…
Reference in New Issue