55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class EnemyStateAttack : IEnemyState
|
|
{
|
|
private EnemyController _enemyController;
|
|
private Animator _animator;
|
|
private Coroutine _attackRoutine;
|
|
|
|
public void Enter(EnemyController enemyController)
|
|
{
|
|
_enemyController = enemyController;
|
|
_animator = _enemyController.EnemyAnimator;
|
|
|
|
_animator.SetBool("Attack", true);
|
|
_attackRoutine = _enemyController.StartCoroutine(AttackSequence());
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
}
|
|
|
|
private IEnumerator AttackSequence()
|
|
{
|
|
// 1. 전조 이펙트 생성
|
|
|
|
// 2. 검을 들어올림
|
|
yield return new WaitForSeconds(3f);
|
|
|
|
// 3. 대기(전조와 검 들어올리는 애니메이션을 위함)
|
|
|
|
// 4. 전조 제거
|
|
|
|
// 5. 검 휘두르기
|
|
_animator.SetTrigger("VertiSlash");
|
|
|
|
// 6. 공격 판정 발생
|
|
|
|
yield return new WaitForSeconds(1f);
|
|
// 7. 애니메이션 트리거 종료 -> 애니메이터 상태 머신으로 처리
|
|
_enemyController.SetState(EnemyState.Trace);
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
if (_attackRoutine != null)
|
|
{
|
|
_enemyController.StopCoroutine(_attackRoutine);
|
|
_attackRoutine = null;
|
|
}
|
|
_animator.SetBool("Attack", false);
|
|
_animator = null;
|
|
_enemyController = null;
|
|
}
|
|
} |