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.
51 lines
1.4 KiB
51 lines
1.4 KiB
using UnityEngine;
|
|
|
|
public class IVMateAppear : IState
|
|
{
|
|
IVMate owner;
|
|
IVCharacter player;
|
|
|
|
StateHandler stateHandler;
|
|
|
|
public IVMateAppear(IVMate owner, IVCharacter player, Vector2 lookDir, Transform spawnPosition)
|
|
{
|
|
this.owner = owner;
|
|
this.player = player;
|
|
|
|
if (spawnPosition != null)
|
|
{
|
|
owner.transform.position = spawnPosition.position;
|
|
}
|
|
else
|
|
{
|
|
var rnd = Random.insideUnitCircle * GameProperty.Instance.DistFromPlayerWhenFirstMateSpawn;
|
|
owner.transform.position = player.transform.position + new Vector3(rnd.x, rnd.y, 0f);
|
|
}
|
|
|
|
owner.ChangeLookDirection(lookDir);
|
|
}
|
|
|
|
public void Enter(StateHandler excutor)
|
|
{
|
|
stateHandler = excutor;
|
|
|
|
#if UNITY_EDITOR
|
|
if(owner.SkeletonAnimation != null && owner.SkeletonAnimation.TryGetAnimation("warp_in", out Spine.Animation _))
|
|
#endif
|
|
{
|
|
owner.SkeletonAnimation.AnimationState.SetAnimation(0, "warp_in", false);
|
|
}
|
|
}
|
|
|
|
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()
|
|
{
|
|
stateHandler = null;
|
|
}
|
|
}
|