그로기 패턴
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// 보스의 페이즈를 관리하는 컴포넌트. 같은 GameObject의 Enemy(몸)·BossAI(두뇌)와
|
||||
// 함께 동작한다.
|
||||
// - Health 비율이 임계값 아래로 떨어지면 페이즈 전환
|
||||
// - 전환 중엔 Enemy.SetInvulnerable(true)로 무적 + 전환 애니메이션 재생
|
||||
// - 전환 중엔 무방비(그로기) 상태로 전환 애니메이션 재생 — 무적 아님, 피격 허용
|
||||
// - CurrentPhase를 BossAI가 읽어 공격 패턴을 바꾼다 (BossAttack.MinPhase)
|
||||
// ============================================================================
|
||||
[RequireComponent(typeof(Enemy))]
|
||||
@@ -18,9 +18,8 @@ public class Boss : MonoBehaviour
|
||||
// 페이즈 업이 일어나는 HP 비율 (내림차순). 예: {0.66, 0.33} → 페이즈 0→1→2.
|
||||
[SerializeField] private float[] _phaseThresholds = { 0.66f, 0.33f };
|
||||
[SerializeField] private string _phaseTransitionAnimation = "BossPhaseChange";
|
||||
[SerializeField] private float _phaseTransitionDuration = 1.2f; // 전환(무적) 지속 시간
|
||||
[SerializeField] private float _phaseTransitionDuration = 1.2f; // 전환(그로기) 지속 시간
|
||||
|
||||
private Enemy _enemy;
|
||||
private Health _health;
|
||||
private Animator _anim;
|
||||
|
||||
@@ -33,7 +32,6 @@ public class Boss : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_enemy = GetComponent<Enemy>();
|
||||
_health = GetComponent<Health>();
|
||||
_anim = GetComponentInChildren<Animator>();
|
||||
}
|
||||
@@ -48,15 +46,17 @@ private void Update()
|
||||
RunPhaseTransition();
|
||||
}
|
||||
|
||||
// 페이즈 전환: 무적 ON → 전환 애니메이션 → 일정 시간 후 무적 OFF + 페이즈 증가.
|
||||
// 페이즈 전환: 그로기(무방비) 진입 → 전환 애니메이션 → 일정 시간 후 페이즈 증가.
|
||||
// 전환 중에도 피격 허용(무적 아님). 행동은 BossAI가 IsTransitioning으로 멈춘다.
|
||||
// 코루틴 대신 Awaitable 사용. destroyCancellationToken으로 파괴 시 자동 취소.
|
||||
private async void RunPhaseTransition()
|
||||
{
|
||||
_isTransitioning = true;
|
||||
_enemy.SetInvulnerable(true);
|
||||
|
||||
if (_anim != null && !string.IsNullOrEmpty(_phaseTransitionAnimation))
|
||||
{
|
||||
_anim.Play(_phaseTransitionAnimation);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -68,7 +68,6 @@ private async void RunPhaseTransition()
|
||||
}
|
||||
|
||||
_currentPhase++;
|
||||
_enemy.SetInvulnerable(false);
|
||||
_isTransitioning = false;
|
||||
OnPhaseChanged?.Invoke(_currentPhase);
|
||||
}
|
||||
|
||||
@@ -102,9 +102,20 @@ private void Update()
|
||||
TickCooldowns();
|
||||
ResolveTarget();
|
||||
|
||||
// 사망 / 행동 불가(피격 경직·잡힘) / 페이즈 전환 중 / 타겟 없음 → 정지 + 진행 중 행동 취소.
|
||||
if (_health.IsDead || !_enemy.CanUseAI
|
||||
|| (_boss != null && _boss.IsTransitioning) || _target == null)
|
||||
// 페이즈 전환 중: 행동만 멈추고 애니메이션은 건드리지 않는다.
|
||||
// (Boss가 BossPhaseChange를 재생 중 — 여기서 SetState(Idle)하면 그 애니가 덮인다.)
|
||||
if (_boss != null && _boss.IsTransitioning)
|
||||
{
|
||||
if (_isAttacking) CancelAttack();
|
||||
CancelRunningSkill();
|
||||
StopMoving();
|
||||
_state = AIState.Idle;
|
||||
_activeAnimationState = null; // 전환 종료 후 SetState가 다시 정상 재생되도록 무효화
|
||||
return;
|
||||
}
|
||||
|
||||
// 사망 / 행동 불가(피격 경직·잡힘) / 타겟 없음 → 정지 + 진행 중 행동 취소.
|
||||
if (_health.IsDead || !_enemy.CanUseAI || _target == null)
|
||||
{
|
||||
if (_isAttacking) CancelAttack();
|
||||
CancelRunningSkill();
|
||||
|
||||
Reference in New Issue
Block a user