You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
public class IVMateCastSkill : IState
|
|
{
|
|
IVMate owner;
|
|
IVCharacter player;
|
|
|
|
StateHandler stateHandler;
|
|
|
|
public IVMateCastSkill(IVMate owner, IVCharacter player)
|
|
{
|
|
this.owner = owner;
|
|
this.player = player;
|
|
}
|
|
|
|
public void Enter(StateHandler excutor)
|
|
{
|
|
stateHandler = excutor;
|
|
|
|
#if UNITY_EDITOR
|
|
if (owner.SkeletonAnimation != null && owner.SkeletonAnimation.TryGetAnimation("skill", out Spine.Animation _))
|
|
#endif
|
|
{
|
|
owner.SkeletonAnimation.AnimationState.SetAnimation(0, "skill", false);
|
|
owner.SkeletonAnimation.AnimationState.Event += OnSkillEvent;
|
|
}
|
|
|
|
owner.Skill.transform.position = owner.CenterPivot;
|
|
owner.Skill.StartCoolTime();
|
|
}
|
|
|
|
public void Excute()
|
|
{
|
|
var trackEntry = owner.SkeletonAnimation != null ? owner.SkeletonAnimation.AnimationState.GetCurrent(0) : null;
|
|
if (trackEntry is null || trackEntry.IsComplete)
|
|
stateHandler.ChangeState(new IVMateIdle(owner, player));
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
#if UNITY_EDITOR
|
|
if (owner.SkeletonAnimation != null)
|
|
#endif
|
|
{
|
|
owner.SkeletonAnimation.AnimationState.Event -= OnSkillEvent;
|
|
}
|
|
|
|
stateHandler = null;
|
|
}
|
|
|
|
private void OnSkillEvent(Spine.TrackEntry trackEntry, Spine.Event e)
|
|
{
|
|
if (e.Data.Name == "cast")
|
|
{
|
|
owner.Skill.transform.position = owner.CenterPivot;
|
|
owner.Skill.Cast(owner);
|
|
}
|
|
}
|
|
}
|