2026-04-22 15:58:44 +00:00
|
|
|
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.
|
2026-04-23 14:47:51 +00:00
|
|
|
/// BT5-Dev 2단계 개정: 기획 04 §3·§5 준수 — "위에서 밟기" 판정 폐기, i-frame 체크된 피격 로직으로 교체.
|
|
|
|
|
/// 적 처치는 PlayerAttack 이벤트 + AttackHitbox 공격 판정 경로로 일원화.
|
|
|
|
|
/// 적과 접촉 시 플레이어는 i-frame 내라면 피해 없음, 아니면 라이프 1 → 사망 체인 발동.
|
2026-04-22 15:58:44 +00:00
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="EnemyCollision"></typeparam>
|
|
|
|
|
public class PlayerEnemyCollision : Simulation.Event<PlayerEnemyCollision>
|
|
|
|
|
{
|
|
|
|
|
public EnemyController enemy;
|
|
|
|
|
public PlayerController player;
|
|
|
|
|
|
|
|
|
|
PlatformerModel model = Simulation.GetModel<PlatformerModel>();
|
|
|
|
|
|
|
|
|
|
public override void Execute()
|
|
|
|
|
{
|
2026-04-23 14:47:51 +00:00
|
|
|
if (player == null || player.health == null) return;
|
2026-04-22 15:58:44 +00:00
|
|
|
|
2026-04-23 14:47:51 +00:00
|
|
|
// i-frame 내에는 피해 무효 (Health.Decrement가 내부에서 체크)
|
|
|
|
|
// — 접촉 지속 동안 연속 히트되는 것을 방지
|
|
|
|
|
if (player.health.IsInvulnerable) return;
|
|
|
|
|
|
|
|
|
|
// 적과 접촉 → 플레이어 피해 (Health.Decrement가 i-frame 활성화)
|
|
|
|
|
player.health.Decrement();
|
|
|
|
|
|
|
|
|
|
// HP 0 도달 시 HealthIsZero 이벤트가 PlayerDeath 체인을 발동 (기존 경로)
|
|
|
|
|
// 여기서 Schedule<PlayerDeath> 직접 호출은 중복이므로 제거 — Health 이벤트 체인 신뢰
|
2026-04-22 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|