2026-05-19 무기추가
진행중인 사항 - InputManager + .inputactions: WeaponSlot1/2/3 액션 추가, 키 1/2/3 매핑 PlayerController 통합: Player에 PlayerWeaponInventory 컴포넌트 자동 부착 OnWeaponChanged 구독 → idle/walk State 이름 동적 교체 OnPunchInput 분기: 무장 시 weapon.AttackRootNode 사용 WeaponSlot 입력 핸들러 3개 추가 (EquipUnarmed / EquipSlot(0) / EquipSlot(1))
This commit is contained in:
@@ -42,6 +42,11 @@ public class Enemy : MonoBehaviour, IDamageable
|
||||
[SerializeField] private LayerMask _separationLayer; // 검사 대상 레이어 (보통 Enemy)
|
||||
private static readonly Collider2D[] _separationBuffer = new Collider2D[16]; // OverlapCircle 결과 버퍼 (GC 회피)
|
||||
|
||||
// ─── 사망 시 드랍 ───────────────────────────────────────────────────
|
||||
[Header("Drop")]
|
||||
[SerializeField] private WeaponData _dropWeapon; // null이면 드랍 안 함
|
||||
[SerializeField] private WeaponPickup _weaponPickupPrefab; // 픽업 오브젝트 프리팹 (한 종류 공유 가능)
|
||||
|
||||
private Health _health; // HP 컴포넌트 (별도 분리 → 플레이어도 같은 컴포넌트 재사용 가능)
|
||||
private Rigidbody2D _rb;
|
||||
private Animator _anim;
|
||||
@@ -448,10 +453,19 @@ private void BounceOffWall(Vector2 wallNormal)
|
||||
}
|
||||
|
||||
// Health.OnDied 이벤트 콜백. 사망 처리.
|
||||
// 현재는 단순 Destroy. 나중에 풀링/드롭/이펙트 추가하려면 여기에 확장.
|
||||
// _dropWeapon이 설정돼 있고 픽업 프리팹이 있으면 자기 위치에 무기 드랍.
|
||||
private void HandleDeath()
|
||||
{
|
||||
Debug.Log($"{name} 사망");
|
||||
DropWeaponIfAny();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void DropWeaponIfAny()
|
||||
{
|
||||
if (_dropWeapon == null || _weaponPickupPrefab == null) return;
|
||||
|
||||
WeaponPickup pickup = Instantiate(_weaponPickupPrefab, transform.position, Quaternion.identity);
|
||||
pickup.Initialize(_dropWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user