2025-07-09 09:45:11 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public class RestaurantCharacterAnimation : MonoBehaviour
|
|
|
|
{
|
2025-07-14 05:07:15 +00:00
|
|
|
private RestaurantPlayerMovement _restaurantPlayerMovement;
|
|
|
|
private SpineController _spineController;
|
2025-07-11 05:48:49 +00:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
2025-07-14 05:07:15 +00:00
|
|
|
_restaurantPlayerMovement = GetComponent<RestaurantPlayerMovement>();
|
|
|
|
_spineController = GetComponent<SpineController>();
|
2025-07-11 05:48:49 +00:00
|
|
|
}
|
|
|
|
|
2025-07-14 06:37:43 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
_restaurantPlayerMovement.OnMoving += OnMove;
|
|
|
|
_restaurantPlayerMovement.OnDashing += OnDash;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
if (_restaurantPlayerMovement)
|
|
|
|
{
|
|
|
|
_restaurantPlayerMovement.OnMoving -= OnMove;
|
|
|
|
_restaurantPlayerMovement.OnDashing -= OnDash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-14 05:07:15 +00:00
|
|
|
private void OnMove(bool isMoving)
|
2025-07-11 05:48:49 +00:00
|
|
|
{
|
2025-07-14 05:07:15 +00:00
|
|
|
string animationName = isMoving ? RestaurantPlayerAnimation.Walk : RestaurantPlayerAnimation.Idle;
|
|
|
|
_spineController.PlayAnimation(animationName, true);
|
2025-07-11 05:48:49 +00:00
|
|
|
}
|
|
|
|
|
2025-07-14 05:07:15 +00:00
|
|
|
private void OnDash(float dashTime)
|
2025-07-11 05:48:49 +00:00
|
|
|
{
|
2025-07-14 05:07:15 +00:00
|
|
|
_spineController.PlayAnimationDuration(RestaurantPlayerAnimation.Dash, false, duration:dashTime);
|
2025-07-11 05:48:49 +00:00
|
|
|
}
|
2025-07-09 09:45:11 +00:00
|
|
|
}
|
|
|
|
}
|