using System.Collections;
using System.Collections.Generic;
using Platformer.Core;
using Platformer.Model;
using UnityEngine;
namespace Platformer.Gameplay
{
///
/// Fired when the player has died.
///
///
public class PlayerDeath : Simulation.Event
{
PlatformerModel model = Simulation.GetModel();
public override void Execute()
{
var player = model.player;
if (player.health.IsAlive)
{
player.health.Die();
model.virtualCamera.Follow = null;
model.virtualCamera.LookAt = null;
// player.collider.enabled = false;
player.controlEnabled = false;
if (player.audioSource && player.ouchAudio)
player.audioSource.PlayOneShot(player.ouchAudio);
// PD 지시 2026-05-13 — 사망 모션 시각 위치 보정 y -0.3 (sprite 위로 떠 보이는 현상 정정)
player.transform.position += new Vector3(0f, -0.3f, 0f);
// PD 지시 2026-05-13 — Player 사망 시 사라지는 현상 fix — Rigidbody2D.simulated=false (gravity 정지·제자리 사망·낙사 차단)
var body = player.GetComponent();
if (body != null) body.simulated = false;
player.animator.SetTrigger("hurt");
player.animator.SetBool("dead", true);
Simulation.Schedule(2);
}
}
}
}