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(); } if (theWaltzOfTheSword == null) { theWaltzOfTheSword = combatPlayerController.MainSkillObject.GetComponent(); } 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; } } }