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.
48 lines
1.4 KiB
48 lines
1.4 KiB
using UnityEngine;
|
|
|
|
public class IVMateAppear : State<IVMate>
|
|
{
|
|
IVCharacter player;
|
|
|
|
IVMateIdle idleState;
|
|
|
|
public void Setup(IVCharacter player, Vector2 lookDir, Transform spawnPosition)
|
|
{
|
|
this.player = player;
|
|
|
|
if (spawnPosition != null)
|
|
{
|
|
Owner.Excutor.transform.position = spawnPosition.position;
|
|
}
|
|
else
|
|
{
|
|
var rnd = Random.insideUnitCircle * GameProperty.Instance.DistFromPlayerWhenFirstMateSpawn;
|
|
Owner.Excutor.transform.position = player.transform.position + new Vector3(rnd.x, rnd.y, 0f);
|
|
}
|
|
|
|
Owner.Excutor.ChangeLookDirection(lookDir);
|
|
}
|
|
|
|
protected override void OnInitialize()
|
|
{
|
|
Owner.TryGetState(out idleState);
|
|
|
|
Debug.Assert(idleState != null, "idleState is null");
|
|
}
|
|
|
|
public override void Enter()
|
|
{
|
|
Debug.Assert(Owner.Excutor.SkeletonAnimation != null && Owner.Excutor.SkeletonAnimation.TryGetAnimation("warp_in", out Spine.Animation _), "SkeletonAnimation is null or wrap_in animation not exist");
|
|
Owner.Excutor.SkeletonAnimation.AnimationState.SetAnimation(0, "warp_in", false);
|
|
}
|
|
|
|
public override void Excute()
|
|
{
|
|
var trackEntry = Owner.Excutor.SkeletonAnimation.AnimationState.GetCurrent(0);
|
|
if (trackEntry is null || trackEntry.IsComplete)
|
|
{
|
|
idleState.Setup(player);
|
|
Owner.ChangeState<IVMateIdle>();
|
|
}
|
|
}
|
|
}
|