그로기 패턴
This commit is contained in:
BIN
Assets/01_Scenes/BossScene.unity
LFS
BIN
Assets/01_Scenes/BossScene.unity
LFS
Binary file not shown.
@@ -7,7 +7,7 @@
|
|||||||
// 보스의 페이즈를 관리하는 컴포넌트. 같은 GameObject의 Enemy(몸)·BossAI(두뇌)와
|
// 보스의 페이즈를 관리하는 컴포넌트. 같은 GameObject의 Enemy(몸)·BossAI(두뇌)와
|
||||||
// 함께 동작한다.
|
// 함께 동작한다.
|
||||||
// - Health 비율이 임계값 아래로 떨어지면 페이즈 전환
|
// - Health 비율이 임계값 아래로 떨어지면 페이즈 전환
|
||||||
// - 전환 중엔 Enemy.SetInvulnerable(true)로 무적 + 전환 애니메이션 재생
|
// - 전환 중엔 무방비(그로기) 상태로 전환 애니메이션 재생 — 무적 아님, 피격 허용
|
||||||
// - CurrentPhase를 BossAI가 읽어 공격 패턴을 바꾼다 (BossAttack.MinPhase)
|
// - CurrentPhase를 BossAI가 읽어 공격 패턴을 바꾼다 (BossAttack.MinPhase)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
[RequireComponent(typeof(Enemy))]
|
[RequireComponent(typeof(Enemy))]
|
||||||
@@ -18,9 +18,8 @@ public class Boss : MonoBehaviour
|
|||||||
// 페이즈 업이 일어나는 HP 비율 (내림차순). 예: {0.66, 0.33} → 페이즈 0→1→2.
|
// 페이즈 업이 일어나는 HP 비율 (내림차순). 예: {0.66, 0.33} → 페이즈 0→1→2.
|
||||||
[SerializeField] private float[] _phaseThresholds = { 0.66f, 0.33f };
|
[SerializeField] private float[] _phaseThresholds = { 0.66f, 0.33f };
|
||||||
[SerializeField] private string _phaseTransitionAnimation = "BossPhaseChange";
|
[SerializeField] private string _phaseTransitionAnimation = "BossPhaseChange";
|
||||||
[SerializeField] private float _phaseTransitionDuration = 1.2f; // 전환(무적) 지속 시간
|
[SerializeField] private float _phaseTransitionDuration = 1.2f; // 전환(그로기) 지속 시간
|
||||||
|
|
||||||
private Enemy _enemy;
|
|
||||||
private Health _health;
|
private Health _health;
|
||||||
private Animator _anim;
|
private Animator _anim;
|
||||||
|
|
||||||
@@ -33,7 +32,6 @@ public class Boss : MonoBehaviour
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_enemy = GetComponent<Enemy>();
|
|
||||||
_health = GetComponent<Health>();
|
_health = GetComponent<Health>();
|
||||||
_anim = GetComponentInChildren<Animator>();
|
_anim = GetComponentInChildren<Animator>();
|
||||||
}
|
}
|
||||||
@@ -48,15 +46,17 @@ private void Update()
|
|||||||
RunPhaseTransition();
|
RunPhaseTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 페이즈 전환: 무적 ON → 전환 애니메이션 → 일정 시간 후 무적 OFF + 페이즈 증가.
|
// 페이즈 전환: 그로기(무방비) 진입 → 전환 애니메이션 → 일정 시간 후 페이즈 증가.
|
||||||
|
// 전환 중에도 피격 허용(무적 아님). 행동은 BossAI가 IsTransitioning으로 멈춘다.
|
||||||
// 코루틴 대신 Awaitable 사용. destroyCancellationToken으로 파괴 시 자동 취소.
|
// 코루틴 대신 Awaitable 사용. destroyCancellationToken으로 파괴 시 자동 취소.
|
||||||
private async void RunPhaseTransition()
|
private async void RunPhaseTransition()
|
||||||
{
|
{
|
||||||
_isTransitioning = true;
|
_isTransitioning = true;
|
||||||
_enemy.SetInvulnerable(true);
|
|
||||||
|
|
||||||
if (_anim != null && !string.IsNullOrEmpty(_phaseTransitionAnimation))
|
if (_anim != null && !string.IsNullOrEmpty(_phaseTransitionAnimation))
|
||||||
|
{
|
||||||
_anim.Play(_phaseTransitionAnimation);
|
_anim.Play(_phaseTransitionAnimation);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,6 @@ private async void RunPhaseTransition()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_currentPhase++;
|
_currentPhase++;
|
||||||
_enemy.SetInvulnerable(false);
|
|
||||||
_isTransitioning = false;
|
_isTransitioning = false;
|
||||||
OnPhaseChanged?.Invoke(_currentPhase);
|
OnPhaseChanged?.Invoke(_currentPhase);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,9 +102,20 @@ private void Update()
|
|||||||
TickCooldowns();
|
TickCooldowns();
|
||||||
ResolveTarget();
|
ResolveTarget();
|
||||||
|
|
||||||
// 사망 / 행동 불가(피격 경직·잡힘) / 페이즈 전환 중 / 타겟 없음 → 정지 + 진행 중 행동 취소.
|
// 페이즈 전환 중: 행동만 멈추고 애니메이션은 건드리지 않는다.
|
||||||
if (_health.IsDead || !_enemy.CanUseAI
|
// (Boss가 BossPhaseChange를 재생 중 — 여기서 SetState(Idle)하면 그 애니가 덮인다.)
|
||||||
|| (_boss != null && _boss.IsTransitioning) || _target == null)
|
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();
|
if (_isAttacking) CancelAttack();
|
||||||
CancelRunningSkill();
|
CancelRunningSkill();
|
||||||
|
|||||||
@@ -2492,6 +2492,32 @@ AnimatorState:
|
|||||||
m_MirrorParameter:
|
m_MirrorParameter:
|
||||||
m_CycleOffsetParameter:
|
m_CycleOffsetParameter:
|
||||||
m_TimeParameter:
|
m_TimeParameter:
|
||||||
|
--- !u!1102 &5431523256479470853
|
||||||
|
AnimatorState:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: BossPhaseChange
|
||||||
|
m_Speed: 0.1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_Transitions: []
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
|
m_IKOnFeet: 0
|
||||||
|
m_WriteDefaultValues: 1
|
||||||
|
m_Mirror: 0
|
||||||
|
m_SpeedParameterActive: 0
|
||||||
|
m_MirrorParameterActive: 0
|
||||||
|
m_CycleOffsetParameterActive: 0
|
||||||
|
m_TimeParameterActive: 0
|
||||||
|
m_Motion: {fileID: 7400000, guid: 7086770aa204ee2408b4c6f0c2306b40, type: 2}
|
||||||
|
m_Tag:
|
||||||
|
m_SpeedParameter:
|
||||||
|
m_MirrorParameter:
|
||||||
|
m_CycleOffsetParameter:
|
||||||
|
m_TimeParameter:
|
||||||
--- !u!1102 &5479087345942455103
|
--- !u!1102 &5479087345942455103
|
||||||
AnimatorState:
|
AnimatorState:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
@@ -3266,6 +3292,9 @@ AnimatorStateMachine:
|
|||||||
- serializedVersion: 1
|
- serializedVersion: 1
|
||||||
m_State: {fileID: 2586254138909662861}
|
m_State: {fileID: 2586254138909662861}
|
||||||
m_Position: {x: 2480, y: 360, z: 0}
|
m_Position: {x: 2480, y: 360, z: 0}
|
||||||
|
- serializedVersion: 1
|
||||||
|
m_State: {fileID: 5431523256479470853}
|
||||||
|
m_Position: {x: 300, y: 410, z: 0}
|
||||||
m_ChildStateMachines: []
|
m_ChildStateMachines: []
|
||||||
m_AnyStateTransitions: []
|
m_AnyStateTransitions: []
|
||||||
m_EntryTransitions: []
|
m_EntryTransitions: []
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user