Health/Assets/Scripts/UI/Component/GudieAnimationManager.cs

46 lines
1.0 KiB
C#
Raw Normal View History

2023-11-10 08:12:37 +00:00
using System.Collections;
2023-11-07 13:55:35 +00:00
using System.Collections.Generic;
using UnityEngine;
public class GudieAnimationManager : MonoBehaviour
{
private Animator _animator;
2023-11-10 08:12:37 +00:00
private string _currName;
2023-11-07 13:55:35 +00:00
private void Awake()
{
_animator = transform.GetComponentInChildren<Animator>();
}
public void Play(string name)
{
_animator.CrossFade(name, 0.5f);
2023-11-10 08:12:37 +00:00
_currName = name;
}
private void Update()
{
if (string.IsNullOrEmpty(_currName))
return;
//当未达到指标且动画播放完毕时,重新播放
if (_animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f)
{
if (YogaManager.Instance.CurrentActionCount < YogaManager.Instance.MaxActionCount)
{
_animator.Play(_currName, 0, 0.0f);
}
}
2023-11-07 13:55:35 +00:00
}
2023-11-10 07:17:23 +00:00
public void Stop()
{
_animator.StopPlayback();
}
2023-11-07 13:55:35 +00:00
public void FrameEstimate()
{
2023-11-10 08:12:37 +00:00
EventManager.Instance.Dispatch(YogaEventType.PoseEstimate);
2023-11-07 13:55:35 +00:00
}
}