85 lines
3.1 KiB
C#
85 lines
3.1 KiB
C#
using UnityEngine;
|
|
using Platformer.Mechanics;
|
|
|
|
namespace EerieVillage.Skills.Effectors
|
|
{
|
|
/// <summary>
|
|
/// 상태 효과 일괄 적용기.
|
|
/// Projectile.OnTriggerEnter2D 등 타격 판정 후 ActiveSkillData 필드를 읽어
|
|
/// DoT·Stun·Slow·Knockback·DebuffStack 을 EnemyController 에 적용한다.
|
|
/// BT12-Dev Phase 2-B §4-5.
|
|
/// </summary>
|
|
public static class StatusApplier
|
|
{
|
|
public static void Apply(ActiveSkillData data, EnemyController enemy)
|
|
{
|
|
if (data == null || enemy == null) return;
|
|
|
|
// DoT (화염·독 등) — DotDuration > 0 && DotInterval > 0
|
|
if (data.DotDuration > 0f && data.DotInterval > 0f)
|
|
{
|
|
ApplyDoT(enemy, data.BaseDamage, data.DotDuration, data.DotInterval);
|
|
}
|
|
|
|
// 기절 (스턴)
|
|
if (data.StunDuration > 0f)
|
|
{
|
|
ApplyStun(enemy, data.StunDuration);
|
|
}
|
|
|
|
// 감속 (슬로우)
|
|
if (data.SlowDuration > 0f && data.SlowMultiplier < 1.0f)
|
|
{
|
|
ApplySlow(enemy, data.SlowDuration, data.SlowMultiplier);
|
|
}
|
|
|
|
// 넉백
|
|
if (data.KnockbackForce > 0f)
|
|
{
|
|
ApplyKnockback(enemy, data.KnockbackForce);
|
|
}
|
|
|
|
// 저주 스택 (A08 저주의 화살)
|
|
if (data.DebuffStackLimit > 0)
|
|
{
|
|
DebuffStack.AddStack(enemy, data.DebuffStackLimit, data.BaseDamage);
|
|
}
|
|
}
|
|
|
|
// -------------------------------------------------------------------
|
|
// 내부 헬퍼
|
|
// -------------------------------------------------------------------
|
|
|
|
private static void ApplyDoT(EnemyController enemy, int damagePerTick, float duration, float interval)
|
|
{
|
|
var existing = enemy.GetComponent<EnemyDoTState>();
|
|
if (existing == null) existing = enemy.gameObject.AddComponent<EnemyDoTState>();
|
|
existing.AddDoT(damagePerTick, duration, interval);
|
|
}
|
|
|
|
private static void ApplyStun(EnemyController enemy, float duration)
|
|
{
|
|
var existing = enemy.GetComponent<EnemyStunState>();
|
|
if (existing == null) existing = enemy.gameObject.AddComponent<EnemyStunState>();
|
|
existing.ApplyStun(duration);
|
|
}
|
|
|
|
private static void ApplySlow(EnemyController enemy, float duration, float multiplier)
|
|
{
|
|
var existing = enemy.GetComponent<EnemySlowState>();
|
|
if (existing == null) existing = enemy.gameObject.AddComponent<EnemySlowState>();
|
|
existing.ApplySlow(duration, multiplier);
|
|
}
|
|
|
|
private static void ApplyKnockback(EnemyController enemy, float force)
|
|
{
|
|
var rb = enemy.GetComponent<Rigidbody2D>();
|
|
if (rb != null)
|
|
{
|
|
// facing 반대 방향 넉백 — 단순 +x 방향 (Phase 2 범위, Phase 2-C에서 방향 정합 예정)
|
|
rb.AddForce(Vector2.right * force, ForceMode2D.Impulse);
|
|
}
|
|
}
|
|
}
|
|
}
|