using Platformer.Core; using Platformer.Mechanics; using Platformer.Model; using UnityEngine; using static Platformer.Core.Simulation; namespace Platformer.Gameplay { /// /// 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 동안에도 밟기는 가능. /// /// public class PlayerEnemyCollision : Simulation.Event { public EnemyController enemy; public PlayerController player; /// BT5-Dev #16 — EnemyController.Update에서 측정한 Player·Enemy y 차 (밟기 판정 영역). public float dyAtCollision; PlatformerModel model = Simulation.GetModel(); public override void Execute() { if (player == null || player.health == null || enemy == null) return; // BT5-Dev #16 — Distance 기반 밟기 판정. dyAtCollision > stompMinDy = Player가 Enemy 위에서 밟음. bool stomped = dyAtCollision > enemy.stompMinDy; Debug.Log($"[PEC] stomped={stomped} dy={dyAtCollision:F2} (threshold>{enemy.stompMinDy}) pInvuln={player.health.IsInvulnerable}"); if (stomped) { Schedule().enemy = enemy; player.Bounce(player.jumpTakeOffSpeed / 3f); return; } // 측면·아래 충돌 — i-frame 적용 피격 if (player.health.IsInvulnerable) return; player.health.Decrement(); } } }