47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
![]() |
using UnityEngine;
|
||
|
|
||
|
namespace DDD
|
||
|
{
|
||
|
public class RestaurantPlayerAnimation : RestaurantCharacterAnimation
|
||
|
{
|
||
|
private RestaurantPlayerMovement _restaurantPlayerMovement;
|
||
|
|
||
|
protected override void Awake()
|
||
|
{
|
||
|
base.Awake();
|
||
|
|
||
|
_restaurantPlayerMovement = GetComponent<RestaurantPlayerMovement>();
|
||
|
}
|
||
|
|
||
|
protected override void Start()
|
||
|
{
|
||
|
base.Start();
|
||
|
|
||
|
_restaurantPlayerMovement.OnMoving += OnMove;
|
||
|
_restaurantPlayerMovement.OnDashing += OnDash;
|
||
|
}
|
||
|
|
||
|
protected override void OnDestroy()
|
||
|
{
|
||
|
base.OnDestroy();
|
||
|
|
||
|
if (_restaurantPlayerMovement)
|
||
|
{
|
||
|
_restaurantPlayerMovement.OnMoving -= OnMove;
|
||
|
_restaurantPlayerMovement.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);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|