fix(BT12-Dev): 밟기 공격 기능 제거 — PlayerEnemyCollision 폐기·Player↔Enemy 충돌 검출 제거

PD: "밟아서 적을 공격 가능한 기능 제거 (관련 기능 모두 삭제)"
PD: "몬스터는 Player 공격에만 피해를 받음"

변경:
1. PlayerEnemyCollision.cs·meta 삭제
   - 점프+위 = EnemyDeath·Bounce 로직 폐기
   - 지상 측면·아래 = i-frame 피격 로직 폐기
2. EnemyController.cs
   - hitRangeX·hitRangeY·stompMinDy 필드 폐기
   - Update 영역 Player ↔ Enemy Bounds.Intersects 검출 폐기
   - PlayerEnemyCollision Schedule 폐기
   - _cachedPlayer·_diagWasIntersecting·VisualBounds 사용처 폐기
   - Player ↔ Enemy IgnoreCollision Awake 시점 적용 유지 (물리 통과 정합)

회귀 영역 X:
- Enemy 사망 경로: Player Projectile·AttackHitbox → Health.Decrement → Schedule<EnemyDeath> 정합 유지
- Player 피해 경로: 밟기 충돌 폐기·Enemy 공격 로직 후속 PD 지시 대기
- Enemy patrol·발판 통과·Enemy ↔ Enemy 통과·scale 1.19 정합

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
깃 관리자 2026-05-12 11:15:20 +09:00
parent 03a6521631
commit adcb1ac1b1
3 changed files with 4 additions and 150 deletions

View File

@ -1,67 +0,0 @@
using Platformer.Core;
using Platformer.Mechanics;
using Platformer.Model;
using UnityEngine;
using static Platformer.Core.Simulation;
namespace Platformer.Gameplay
{
/// <summary>
/// Fired when a Player collides with an Enemy.
/// BT5-Dev 2단계 (2026-04-23): "위에서 밟기" 판정 폐기 → i-frame 체크 피격 로직.
/// PD 지시 2026-05-07: 밟기 공격 복원. 위에서 밟으면 적 즉사 + Player Bounce.
/// 측면·아래 충돌은 기존 i-frame 피격 로직 유지. 부활 직후 i-frame 동안에도 밟기는 가능.
/// </summary>
/// <typeparam name="EnemyCollision"></typeparam>
public class PlayerEnemyCollision : Simulation.Event<PlayerEnemyCollision>
{
public EnemyController enemy;
public PlayerController player;
/// <summary>BT5-Dev #16 — EnemyController.Update에서 측정한 Player·Enemy y 차 (밟기 판정 영역).</summary>
public float dyAtCollision;
// BT5-Dev #25 — dyAtCollision 영역 = footHeadDelta (Player 발 - Enemy 머리)
// 0 = 닿음 / 양수 = Player 발이 Enemy 머리 위 / 음수 = Player 발이 Enemy 머리 영역 안 영역
// 측면 충돌 시 footHeadDelta 음수 (Player 발 영역 < Enemy 머리 영역)
// 점프 밟기 시 footHeadDelta -0.2 ~ +0.3 영역 (착지 직전·직후)
// BT5-Dev #30 — dyAtCollision 영역 시각 영역 정합 (Player·Enemy 시각 영역 보정 적용)
// 0 = Player 시각 발이 Enemy 시각 머리 정확히 닿음. 음수 = Player 발이 Enemy 영역 안 침투.
const float STOMP_DELTA_MIN = -0.3f; // Enemy 영역 안 0.3 단위 침투까지 허용
const float STOMP_DELTA_MAX = 0.05f; // Enemy 머리 영역 약간 위(0.05)까지 허용
PlatformerModel model = Simulation.GetModel<PlatformerModel>();
public override void Execute()
{
if (player == null || player.health == null || enemy == null) return;
// BT5-Dev #37 — PD 의도 정확 반영: 점프 상태(공중) + Player.y > Enemy.y = 무조건 밟기
// footHeadDelta 좁은 영역(-0.3~0.05) 빠른 떨어짐 한 프레임 miss → 점프+위 단순 조건으로 catch 보장
bool inAir = !player.IsGrounded;
bool playerAbove = player.transform.position.y > enemy.transform.position.y;
#if UNITY_EDITOR && ENEMY_DIAG_VERBOSE
Debug.Log($"[PEC] inAir={inAir} above={playerAbove} delta={dyAtCollision:F2} pY={player.transform.position.y:F2} eY={enemy.transform.position.y:F2}");
#endif
if (inAir && playerAbove)
{
// 점프 + Enemy 위 = 밟기 (Bounce + EnemyDeath)
Schedule<EnemyDeath>().enemy = enemy;
player.Bounce(player.jumpTakeOffSpeed / 3f);
return;
}
if (inAir)
{
// 점프 + Enemy 옆·아래 = 피해 차단 (방어 코드)
return;
}
// 지상 상태 측면·아래 충돌 — i-frame 적용 피격
if (player.health.IsInvulnerable) return;
player.health.Decrement();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c8dbdd402c7594d3984ae281ba568775
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -14,12 +14,8 @@ namespace Platformer.Mechanics
{
public AudioClip ouch;
/// <summary>BT5-Dev #16 — Distance 기반 감지 영역 X 임계값 (전체 폭). 표준 platformer Enemy 옆 닿음 영역 0.6~0.8.</summary>
public float hitRangeX = 0.7f;
/// <summary>Y 임계값. 위/아래 둘 다 인정.</summary>
public float hitRangeY = 1.0f;
/// <summary>밟기 판정 — Player가 Enemy보다 위 거리. 발 닿는 느낌 영역(0.05~0.15).</summary>
public float stompMinDy = 0.1f;
// BT12-Dev 2026-05-11 — 밟기 공격 기능 제거 (PD 지시): hitRangeX·hitRangeY·stompMinDy 폐기.
// Enemy는 Player 공격에만 피해를 받으므로 Player ↔ Enemy 충돌 감지 자체 불필요.
// PD 명시 2026-05-08 — 자동 patrol (생성 위치 기준 좌/우 random 50~75 왕복·BT87 절반 정정)
public float patrolMinRange = 50f;
@ -377,74 +373,10 @@ namespace Platformer.Mechanics
if (control != null) control.move.x = 0f;
}
// 이하 — Player 충돌 검출 영역 (patrol 영역과 분리)
// PD 지시 2026-05-07 — Player ↔ Enemy 통과 가능이지만 Bounds.Intersects로 매 프레임 감지
if (_cachedPlayer == null)
{
// 1차: tag 영역 발견
var pgo = GameObject.FindGameObjectWithTag("Player");
if (pgo != null) _cachedPlayer = pgo.GetComponent<PlayerController>();
// 2차 fallback: tag 영역 미설정 영역에 대비해 PlayerController 영역 직접 검색
if (_cachedPlayer == null)
{
_cachedPlayer = Object.FindFirstObjectByType<PlayerController>();
}
#if UNITY_EDITOR && ENEMY_DIAG_VERBOSE
if (Time.frameCount % 60 == 0)
{
int allCount = Object.FindObjectsByType<PlayerController>(FindObjectsSortMode.None).Length;
Debug.Log($"[BT17-Update@{name}] f={Time.frameCount} cached={(_cachedPlayer != null ? _cachedPlayer.name : "NULL")} pgoTag={(pgo != null ? pgo.name : "NULL")} allPCcount={allCount}");
}
#endif
}
// BT20 — IgnoreCollision 영역 Awake 시점 Player 발견 X 영역 fallback. Update 영역에서 발견 직후 1회 영역 호출.
if (_cachedPlayer != null && !_ignoreCollisionApplied && _collider != null)
{
var pc = _cachedPlayer.GetComponent<Collider2D>();
if (pc != null)
{
Physics2D.IgnoreCollision(_collider, pc, true);
_ignoreCollisionApplied = true;
#if UNITY_EDITOR && ENEMY_DIAG_VERBOSE
Debug.Log($"[BT20-Ignore@{name}] Player↔Enemy IgnoreCollision applied");
#endif
}
}
if (_cachedPlayer != null && _cachedPlayer.health != null && _cachedPlayer.health.IsAlive)
{
// BT5-Dev #36 — Distance 영역 폐기 → Bounds.Intersects 표준 영역 (Unity Physics AABB 정확)
// Player 빠른 통과 시 한 프레임 catch 정합. Layer 13↔14 OFF 영역 통과 가능 영역 그대로.
bool inRange = VisualBounds.Intersects(_cachedPlayer.Bounds);
const float PLAYER_COLLIDER_TO_VISUAL_FOOT = -0.17f;
float footY = _cachedPlayer.Bounds.min.y + PLAYER_COLLIDER_TO_VISUAL_FOOT;
float headY = VisualBounds.max.y;
float footHeadDelta = footY - headY;
if (inRange != _diagWasIntersecting)
{
#if UNITY_EDITOR && ENEMY_DIAG_VERBOSE
Debug.Log($"[EnemyDiag@{name}] inRange={inRange} footHeadDelta={footHeadDelta:F2} VB={VisualBounds.size} PB={_cachedPlayer.Bounds.size}");
#endif
_diagWasIntersecting = inRange;
}
if (inRange)
{
var ev = Schedule<PlayerEnemyCollision>();
ev.player = _cachedPlayer;
ev.enemy = this;
ev.dyAtCollision = footHeadDelta;
}
}
// BT12-Dev 2026-05-11 — 밟기 공격 폐기 (PD 지시): Player ↔ Enemy 충돌 검출·PlayerEnemyCollision 발화 제거.
// Player ↔ Enemy IgnoreCollision은 Awake 시점에 이미 적용되어 물리 통과 정합.
}
bool _diagWasIntersecting;
void OnDrawGizmos()
{
// BT5-Dev #15 진단 — Scene 영역 시각화 (Editor에서만 표시)