44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System.Threading.Tasks;
|
|
using Spine.Unity;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace EventBossFight
|
|
{
|
|
public class EventBossFightTimelineCell : MonoBehaviour
|
|
{
|
|
public SkeletonGraphic spine;
|
|
public SkeletonGraphic Spine => spine??= gameObject.GetComponent<SkeletonGraphic>();
|
|
public string idleName;
|
|
public PlayableAsset idleTimeline;
|
|
public PlayableAsset deathTimeline;
|
|
|
|
public void PlayIdle(PlayableDirector director)
|
|
{
|
|
if (idleTimeline)
|
|
director.Play(idleTimeline, DirectorWrapMode.Loop);
|
|
else
|
|
Spine.AnimationState.SetAnimation(0, idleName, true);
|
|
}
|
|
|
|
protected async Task PlayTimeline(PlayableDirector director, PlayableAsset timeline)
|
|
{
|
|
if (!director)
|
|
return;
|
|
director.Play(timeline, DirectorWrapMode.Hold);
|
|
await Awaiters.Seconds((float)timeline.duration);
|
|
if (timeline != deathTimeline)
|
|
{
|
|
if (idleTimeline)
|
|
director.Play(idleTimeline, DirectorWrapMode.Loop);
|
|
else
|
|
Spine.AnimationState.SetAnimation(0, idleName, true);
|
|
}
|
|
}
|
|
|
|
public async Task PlayTimelineDeath(PlayableDirector director)
|
|
{
|
|
await PlayTimeline(director, deathTimeline);
|
|
}
|
|
}
|
|
} |