38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class ReadyToTheWaltzOfTheSwordBehavior : StateMachineBehaviour
|
|
{
|
|
private CombatPlayerController combatPlayerController;
|
|
private TheWaltzOfTheSword theWaltzOfTheSword;
|
|
|
|
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
if (combatPlayerController == null)
|
|
{
|
|
combatPlayerController = animator.GetComponentInParent<CombatPlayerController>();
|
|
}
|
|
|
|
if (theWaltzOfTheSword == null)
|
|
{
|
|
theWaltzOfTheSword = combatPlayerController.MainSkillObject.GetComponent<TheWaltzOfTheSword>();
|
|
}
|
|
|
|
var animationLength = stateInfo.length;
|
|
animator.speed = animationLength / theWaltzOfTheSword.CastingTime;
|
|
}
|
|
|
|
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
|
|
}
|
|
|
|
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
|
{
|
|
animator.speed = 1f;
|
|
}
|
|
}
|
|
} |