Example #1
0
 void CalculateDuration()
 {
     duration -= Time.deltaTime;
     if (duration <= 0)
     {
         dashState = _DashState.Cooldown;
     }
 }
Example #2
0
 void CalculateCooldown()
 {
     cooldown -= Time.deltaTime;
     if (cooldown <= 0)
     {
         dashState = _DashState.Ready;
         cooldown  = playerStats.DashCooldown;
         duration  = playerStats.DashDuration;
     }
 }
Example #3
0
 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;
 }
Example #4
0
 void Start()
 {
     DashState       = _DashState.Ready;
     playerRigidbody = gameObject.GetComponent <Rigidbody2D>();
     playerStats     = gameObject.GetComponent <PlayerStats>();
 }