2025-08-28 01:40:22 +02:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class PlayerSkillHandler
|
|
|
|
|
{
|
2025-08-28 17:09:35 +02:00
|
|
|
private float dashSpeed;
|
|
|
|
|
private float dashDuration;
|
2025-08-28 01:40:22 +02:00
|
|
|
|
|
|
|
|
private bool isDashing = false;
|
|
|
|
|
|
|
|
|
|
public bool IsDashing() { return isDashing; }
|
|
|
|
|
|
2025-08-28 17:09:35 +02:00
|
|
|
public PlayerSkillHandler(float dashSpeed, float dashDuration)
|
|
|
|
|
{
|
|
|
|
|
this.dashSpeed = dashSpeed;
|
|
|
|
|
this.dashDuration = dashDuration;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 01:40:22 +02:00
|
|
|
public IEnumerator DashCoroutine(CharacterController controller, Vector3 direction)
|
|
|
|
|
{
|
2025-08-28 17:09:35 +02:00
|
|
|
Physics.IgnoreLayerCollision(6, 7, true); // disable collisions between player and enemies
|
2025-08-28 01:40:22 +02:00
|
|
|
float startTime = Time.time;
|
2025-08-28 17:09:35 +02:00
|
|
|
isDashing = true; // just for now. maybe will be removed
|
2025-08-28 01:40:22 +02:00
|
|
|
while (Time.time - startTime < dashDuration)
|
|
|
|
|
{
|
2025-08-28 17:09:35 +02:00
|
|
|
controller.Move(dashSpeed * Time.deltaTime * direction);
|
|
|
|
|
yield return null; // wait one frame
|
2025-08-28 01:40:22 +02:00
|
|
|
}
|
2025-08-28 17:09:35 +02:00
|
|
|
isDashing = false; // just for now. maybe will be removed
|
|
|
|
|
Physics.IgnoreLayerCollision(6, 7, false); // enable collisions between player and enemies
|
2025-08-28 01:40:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|