void CalculateDuration() { duration -= Time.deltaTime; if (duration <= 0) { dashState = _DashState.Cooldown; } }
void CalculateCooldown() { cooldown -= Time.deltaTime; if (cooldown <= 0) { dashState = _DashState.Ready; cooldown = playerStats.DashCooldown; duration = playerStats.DashDuration; } }
void Dash(_DashDirection dashDirection) { cooldown = playerStats.DashCooldown; duration = playerStats.DashDuration; speed = playerStats.DashSpeed; if (dashDirection == _DashDirection.Left) { playerRigidbody.AddForce(-transform.right * speed, ForceMode2D.Impulse); } else if (dashDirection == _DashDirection.Right) { playerRigidbody.AddForce(transform.right * speed, ForceMode2D.Impulse); } cooldown = playerStats.DashCooldown; dashState = _DashState.Dashing; }
void Start() { DashState = _DashState.Ready; playerRigidbody = gameObject.GetComponent <Rigidbody2D>(); playerStats = gameObject.GetComponent <PlayerStats>(); }