2026-05-21 보스추가

This commit is contained in:
2026-05-21 12:12:17 +09:00
parent 7d87b6e007
commit 0f35455ad7
22 changed files with 821 additions and 81 deletions

View File

@@ -50,6 +50,10 @@ public class Enemy : MonoBehaviour, IDamageable
[SerializeField] private WeaponData _dropWeapon; // null이면 드랍 안 함
[SerializeField] private WeaponPickup _weaponPickupPrefab; // 픽업 오브젝트 프리팹 (한 종류 공유 가능)
// ─── 잡기 설정 ───────────────────────────────────────────────────────
[Header("Grab")]
[SerializeField] private bool _isGrabbable = true; // false면 플레이어가 잡을 수 없음 (보스 등)
private Health _health; // HP 컴포넌트 (별도 분리 → 플레이어도 같은 컴포넌트 재사용 가능)
private Rigidbody2D _rb;
private Animator _anim;
@@ -79,8 +83,14 @@ public class Enemy : MonoBehaviour, IDamageable
private Vector2 _grabTargetPosition;// 잡힌 동안 강제로 위치할 좌표
private int _grabSolidMask; // 잡혀서 이동할 때 벽에 끼이지 않게 검사할 솔리드 레이어
// ─── 무적 ────────────────────────────────────────────────────────────
// true면 모든 피격을 무시한다 (보스 페이즈 전환 i-frame 등). SetInvulnerable로 토글.
private bool _isInvulnerable;
public bool IsDead => _health != null && _health.IsDead;
public bool IsGrabbed => _isGrabbed;
public bool IsGrabbable => _isGrabbable;
public bool IsInvulnerable => _isInvulnerable;
public bool IsInHitReaction => _hitStunTimer > 0f || _hitReactionTimer > 0f || _isHitPositionCorrecting || _flashTimer > 0f;
public bool CanUseAI => !IsDead && !_isGrabbed && !IsInHitReaction;
@@ -274,6 +284,8 @@ private void ApplySeparation()
public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReactionAnimationState = null, Vector2? hitTargetPosition = null, bool correctHitTargetY = false, int hitPositionSolidMask = 0, float hitPositionCorrectionDuration = 0f, float hitStunDuration = -1f)
{
if (_health == null || _health.IsDead) return;
// 무적이면 데미지/플래시/넉백 전부 무시.
if (_isInvulnerable) return;
float appliedHitStunDuration = hitStunDuration >= 0f ? hitStunDuration : _hitStunDuration;
_hitStunTimer = Mathf.Max(_hitStunTimer, appliedHitStunDuration);
@@ -306,10 +318,17 @@ public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReac
Debug.Log($"{name} 피격: -{amount} (HP: {_health.CurrentHealth}/{_health.MaxHealth})");
}
// 무적 토글. 보스 페이즈 전환 중 무적 부여 등에 사용 (Boss 컴포넌트가 호출).
public void SetInvulnerable(bool value)
{
_isInvulnerable = value;
}
// 플레이어가 잡기 액션 시작 시 호출. 이 적이 잡힘 상태로 진입.
// 이후 매 FixedUpdate에서 _grabTargetPosition으로 강제 이동됨.
public void BeginGrab(string grabbedAnimationState, int solidMask)
{
if (!_isGrabbable) return;
if (_health == null || _health.IsDead) return;
_isGrabbed = true;