2026-04-22 15:58:44 +00:00
|
|
|
using Platformer.Core;
|
|
|
|
|
using Platformer.Mechanics;
|
2026-05-08 06:24:25 +00:00
|
|
|
using UnityEngine;
|
2026-04-22 15:58:44 +00:00
|
|
|
|
|
|
|
|
namespace Platformer.Gameplay
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fired when the health component on an enemy has a hitpoint value of 0.
|
2026-05-08 06:24:25 +00:00
|
|
|
/// BT104 (PD 명시 2026-05-08): Enemy 사망 시 patrol·시각 영역 비활성 + 1초 후 GameObject Destroy
|
2026-04-22 15:58:44 +00:00
|
|
|
/// </summary>
|
|
|
|
|
public class EnemyDeath : Simulation.Event<EnemyDeath>
|
|
|
|
|
{
|
|
|
|
|
public EnemyController enemy;
|
|
|
|
|
|
|
|
|
|
public override void Execute()
|
|
|
|
|
{
|
2026-05-08 06:24:25 +00:00
|
|
|
if (enemy == null) return;
|
|
|
|
|
|
|
|
|
|
// 충돌·이동·patrol 영역 비활성
|
|
|
|
|
if (enemy._collider != null) enemy._collider.enabled = false;
|
|
|
|
|
if (enemy.control != null) enemy.control.enabled = false;
|
2026-05-08 06:27:12 +00:00
|
|
|
enemy.enabled = false; // EnemyController patrol 영역 정지
|
|
|
|
|
|
|
|
|
|
// BT105 — 제자리 사망 (PD 명시 2026-05-08): Rigidbody2D simulated = false → gravity X·물리 미참여
|
|
|
|
|
var body = enemy.GetComponent<Rigidbody2D>();
|
|
|
|
|
if (body != null) body.simulated = false;
|
2026-05-08 06:24:25 +00:00
|
|
|
|
|
|
|
|
// death 애니메이션 트리거 (Enemy.controller 영역의 'death' parameter)
|
|
|
|
|
var animator = enemy.GetComponent<Animator>();
|
|
|
|
|
if (animator != null) animator.SetTrigger("death");
|
|
|
|
|
|
|
|
|
|
// 사운드
|
|
|
|
|
if (enemy._audio != null && enemy.ouch != null)
|
2026-04-22 15:58:44 +00:00
|
|
|
enemy._audio.PlayOneShot(enemy.ouch);
|
2026-05-08 06:24:25 +00:00
|
|
|
|
|
|
|
|
// 1초 후 GameObject 영역 Destroy (사망 애니메이션 시간)
|
|
|
|
|
Object.Destroy(enemy.gameObject, 1f);
|
2026-05-08 08:53:39 +00:00
|
|
|
|
|
|
|
|
// BT12-MVP-A 영역 신규 (2026-05-08) — 적 처치 시 EXP 발급
|
|
|
|
|
var player = Object.FindFirstObjectByType<PlayerController>();
|
|
|
|
|
EerieVillage.Progression.ExperienceSystem.OnEnemyKilled(enemy, player);
|
2026-04-22 15:58:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|