48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace DDD.Restaurant
|
|
{
|
|
[RequireComponent(typeof(PlayerMovement))]
|
|
public class PlayerAnimation : CharacterAnimation
|
|
{
|
|
private PlayerMovement _playerMovement;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
_playerMovement = GetComponent<PlayerMovement>();
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
_playerMovement.OnMoving += OnMove;
|
|
_playerMovement.OnDashing += OnDash;
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
base.OnDestroy();
|
|
|
|
if (_playerMovement)
|
|
{
|
|
_playerMovement.OnMoving -= OnMove;
|
|
_playerMovement.OnDashing -= OnDash;
|
|
}
|
|
}
|
|
|
|
private void OnMove(bool isMoving)
|
|
{
|
|
string animationName = isMoving ? RestaurantPlayerAnimationType.Walk : RestaurantPlayerAnimationType.Idle;
|
|
_spineController.PlayAnimation(animationName, true);
|
|
}
|
|
|
|
private void OnDash(float dashTime)
|
|
{
|
|
_spineController.PlayAnimationDuration(RestaurantPlayerAnimationType.Dash, false, duration:dashTime);
|
|
}
|
|
|
|
}
|
|
} |