37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
using UnityEngine;
|
|
using Platformer.Core;
|
|
using Platformer.Mechanics;
|
|
using Platformer.Model;
|
|
|
|
namespace Platformer.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Fired when the player is spawned after dying.
|
|
/// </summary>
|
|
public class PlayerSpawn : Simulation.Event<PlayerSpawn>
|
|
{
|
|
PlatformerModel model = Simulation.GetModel<PlatformerModel>();
|
|
|
|
public override void Execute()
|
|
{
|
|
var player = model.player;
|
|
player.collider2d.enabled = true;
|
|
player.controlEnabled = false;
|
|
if (player.audioSource && player.respawnAudio)
|
|
player.audioSource.PlayOneShot(player.respawnAudio);
|
|
|
|
// PD 지시 2026-05-13 — 제자리 부활 (Teleport 폐기) + Health.Resurrect 호출
|
|
// Resurrect = currentHP=maxHP·invulnerableUntil=2초·Animator dead=false·resurrect Trigger
|
|
// PlayerInvulnerabilityFlash 영역 IsInvulnerable 자동 깜박 (2초)
|
|
player.health.Resurrect();
|
|
|
|
// PD 지시 2026-05-13 — Rigidbody2D.simulated 복원 = EnablePlayerInput 영역 (2초 후) 이전·즉시 X (부활 모션 중 움직임 차단)
|
|
|
|
player.jumpState = PlayerController.JumpState.Grounded;
|
|
// animator.SetBool("dead", false)·SetTrigger("resurrect") = Health.Resurrect 내부 호출됨
|
|
model.virtualCamera.Follow = player.transform;
|
|
model.virtualCamera.LookAt = player.transform;
|
|
Simulation.Schedule<EnablePlayerInput>(2f);
|
|
}
|
|
}
|
|
} |