2025-08-18 10:48:36 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2025-08-27 07:52:34 +00:00
|
|
|
namespace DDD.Restaurant
|
2025-08-18 10:48:36 +00:00
|
|
|
{
|
2025-08-27 08:25:11 +00:00
|
|
|
[RequireComponent(typeof(PlayerMovement))]
|
|
|
|
public class PlayerAnimation : CharacterAnimation
|
2025-08-18 10:48:36 +00:00
|
|
|
{
|
2025-08-27 08:25:11 +00:00
|
|
|
private PlayerMovement _playerMovement;
|
2025-08-18 10:48:36 +00:00
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
{
|
|
|
|
base.Awake();
|
|
|
|
|
2025-08-27 08:25:11 +00:00
|
|
|
_playerMovement = GetComponent<PlayerMovement>();
|
2025-08-18 10:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Start()
|
|
|
|
{
|
|
|
|
base.Start();
|
|
|
|
|
2025-08-27 08:25:11 +00:00
|
|
|
_playerMovement.OnMoving += OnMove;
|
|
|
|
_playerMovement.OnDashing += OnDash;
|
2025-08-18 10:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
{
|
|
|
|
base.OnDestroy();
|
|
|
|
|
2025-08-27 08:25:11 +00:00
|
|
|
if (_playerMovement)
|
2025-08-18 10:48:36 +00:00
|
|
|
{
|
2025-08-27 08:25:11 +00:00
|
|
|
_playerMovement.OnMoving -= OnMove;
|
|
|
|
_playerMovement.OnDashing -= OnDash;
|
2025-08-18 10:48:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|