45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class Dash : StateMachineBehaviour
|
|
{
|
|
private CombatPlayer combatPlayer;
|
|
|
|
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
if (combatPlayer == null)
|
|
{
|
|
combatPlayer = animator.GetComponentInParent<CombatPlayer>();
|
|
}
|
|
combatPlayer.IsDashing = true;
|
|
combatPlayer.EnableDash = false;
|
|
}
|
|
|
|
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
// var dashDirection = combatPlayer.PreviousDirection;
|
|
//
|
|
// if (combatPlayer.IsOnSlope())
|
|
// {
|
|
// dashDirection = Vector3.ProjectOnPlane(dashDirection, combatPlayer.GetSlopeHit().normal).normalized;
|
|
// }
|
|
//
|
|
// combatPlayer.Rb.velocity = dashDirection * combatPlayer.DashForce;
|
|
|
|
if (stateInfo.normalizedTime >= 1.0f)
|
|
{
|
|
animator.SetBool(combatPlayer.isDashingHash, false);
|
|
}
|
|
}
|
|
|
|
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
combatPlayer.IsDashing = false;
|
|
animator.SetBool(combatPlayer.isDashingHash, false);
|
|
|
|
combatPlayer.CoolDown(combatPlayer.DashCooldown, () => combatPlayer.EnableDash = true);
|
|
}
|
|
}
|
|
} |