36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Platformer.Core;
|
|
using Platformer.Mechanics;
|
|
using UnityEngine;
|
|
|
|
namespace Platformer.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Fired when the health component on an enemy has a hitpoint value of 0.
|
|
/// BT104 (PD 명시 2026-05-08): Enemy 사망 시 patrol·시각 영역 비활성 + 1초 후 GameObject Destroy
|
|
/// </summary>
|
|
public class EnemyDeath : Simulation.Event<EnemyDeath>
|
|
{
|
|
public EnemyController enemy;
|
|
|
|
public override void Execute()
|
|
{
|
|
if (enemy == null) return;
|
|
|
|
// 충돌·이동·patrol 영역 비활성
|
|
if (enemy._collider != null) enemy._collider.enabled = false;
|
|
if (enemy.control != null) enemy.control.enabled = false;
|
|
enemy.enabled = false; // BT104: EnemyController patrol 영역 정지
|
|
|
|
// death 애니메이션 트리거 (Enemy.controller 영역의 'death' parameter)
|
|
var animator = enemy.GetComponent<Animator>();
|
|
if (animator != null) animator.SetTrigger("death");
|
|
|
|
// 사운드
|
|
if (enemy._audio != null && enemy.ouch != null)
|
|
enemy._audio.PlayOneShot(enemy.ouch);
|
|
|
|
// 1초 후 GameObject 영역 Destroy (사망 애니메이션 시간)
|
|
Object.Destroy(enemy.gameObject, 1f);
|
|
}
|
|
}
|
|
} |