Refactor: Dash
Repositioned some parts of dash code into skillHandler
This commit is contained in:
@@ -4,24 +4,31 @@ using UnityEngine;
|
||||
|
||||
public class PlayerSkillHandler
|
||||
{
|
||||
private float dashSpeed = 15f;
|
||||
private float dashDuration = 0.2f;
|
||||
private float dashSpeed;
|
||||
private float dashDuration;
|
||||
|
||||
private bool isDashing = false;
|
||||
|
||||
public bool IsDashing() { return isDashing; }
|
||||
|
||||
public PlayerSkillHandler(float dashSpeed, float dashDuration)
|
||||
{
|
||||
this.dashSpeed = dashSpeed;
|
||||
this.dashDuration = dashDuration;
|
||||
}
|
||||
|
||||
public IEnumerator DashCoroutine(CharacterController controller, Vector3 direction)
|
||||
{
|
||||
|
||||
Physics.IgnoreLayerCollision(6, 7, true); // disable collisions between player and enemies
|
||||
float startTime = Time.time;
|
||||
isDashing = true;
|
||||
isDashing = true; // just for now. maybe will be removed
|
||||
while (Time.time - startTime < dashDuration)
|
||||
{
|
||||
controller.Move(direction * dashSpeed * Time.deltaTime);
|
||||
yield return null;
|
||||
controller.Move(dashSpeed * Time.deltaTime * direction);
|
||||
yield return null; // wait one frame
|
||||
}
|
||||
isDashing = false;
|
||||
isDashing = false; // just for now. maybe will be removed
|
||||
Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user