2026-04-08 스킬시스템 진행중, 폴더구조 변경등
This commit is contained in:
@@ -4,10 +4,19 @@ public class AreaEffect : MonoBehaviour, ISkillEffect
|
||||
{
|
||||
public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
float finalDamage = levelData.Damage * chargeRatio;
|
||||
Vector3 center = caster.position + caster.forward * skill.CurrentLevelData.Range;
|
||||
ApplyArea(skill, caster, center, chargeRatio);
|
||||
}
|
||||
|
||||
Vector3 center = caster.position + caster.forward * levelData.Range;
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio)
|
||||
{
|
||||
ApplyArea(skill, caster, targetPos, chargeRatio);
|
||||
}
|
||||
|
||||
private void ApplyArea(SkillInstance skill, Transform caster, Vector3 center, float chargeRatio)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
int damage = Mathf.RoundToInt(levelData.Damage * chargeRatio);
|
||||
|
||||
if (skill.Data.EffectPrefab != null)
|
||||
{
|
||||
@@ -19,25 +28,21 @@ public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
{
|
||||
if (hit.transform == caster) continue;
|
||||
|
||||
Debug.Log($"[범위] {hit.name}에게 {finalDamage} 데미지");
|
||||
}
|
||||
}
|
||||
IDamageable target = hit.GetComponent<IDamageable>();
|
||||
if (target != null)
|
||||
{
|
||||
target.TakeDamage(damage, caster);
|
||||
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
|
||||
if (skill.Data.EffectPrefab != null)
|
||||
{
|
||||
Instantiate(skill.Data.EffectPrefab, targetPos, Quaternion.identity);
|
||||
}
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(targetPos, levelData.Range);
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
if (hit.transform == caster) continue;
|
||||
|
||||
Debug.Log($"[범위지정] {hit.name}에게 {levelData.Damage} 데미지");
|
||||
if (skill.Data.AppliedDebuffs != null)
|
||||
{
|
||||
StatusEffectReceiver receiver = hit.GetComponent<StatusEffectReceiver>();
|
||||
if (receiver != null)
|
||||
{
|
||||
foreach (var debuff in skill.Data.AppliedDebuffs)
|
||||
receiver.ApplyDebuff(debuff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,10 @@ public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
|
||||
Debug.Log($"버프 적용: {skill.Data.SkillName}, 지속시간 {levelData.Duration}초");
|
||||
}
|
||||
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio)
|
||||
{
|
||||
// 버프는 항상 시전자 대상이므로 Execute와 동일
|
||||
Execute(skill, caster, chargeRatio);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,40 @@ public class DamageEffect : MonoBehaviour, ISkillEffect
|
||||
{
|
||||
public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
float finalDamage = levelData.Damage * chargeRatio;
|
||||
float range = levelData.Range;
|
||||
Vector3 center = caster.position + caster.forward * skill.CurrentLevelData.Range * 0.5f;
|
||||
ApplyDamage(skill, caster, center, chargeRatio);
|
||||
}
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(caster.position + caster.forward * range * 0.5f, range);
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio)
|
||||
{
|
||||
ApplyDamage(skill, caster, targetPos, chargeRatio);
|
||||
}
|
||||
|
||||
private void ApplyDamage(SkillInstance skill, Transform caster, Vector3 center, float chargeRatio)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
int damage = Mathf.RoundToInt(levelData.Damage * chargeRatio);
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(center, levelData.Range);
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
if (hit.transform == caster) continue;
|
||||
|
||||
// IDamageable 등 인터페이스가 있으면 여기서 적용
|
||||
Debug.Log($"{hit.name}에게 {finalDamage} 데미지");
|
||||
IDamageable target = hit.GetComponent<IDamageable>();
|
||||
if (target != null)
|
||||
{
|
||||
target.TakeDamage(damage, caster);
|
||||
|
||||
if (skill.Data.AppliedDebuffs != null)
|
||||
{
|
||||
StatusEffectReceiver receiver = hit.GetComponent<StatusEffectReceiver>();
|
||||
if (receiver != null)
|
||||
{
|
||||
foreach (var debuff in skill.Data.AppliedDebuffs)
|
||||
receiver.ApplyDebuff(debuff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
public interface ISkillEffect
|
||||
{
|
||||
void Execute(SkillInstance skill, Transform caster, float chargeRatio);
|
||||
void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio);
|
||||
}
|
||||
|
||||
@@ -12,4 +12,17 @@ public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
// 투사체에 데미지 정보 전달
|
||||
// proj.GetComponent<Projectile>()?.Init(skill.CurrentLevelData.Damage * chargeRatio);
|
||||
}
|
||||
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio)
|
||||
{
|
||||
if (skill.Data.EffectPrefab == null) return;
|
||||
|
||||
Vector3 spawnPos = caster.position + Vector3.up;
|
||||
Vector3 direction = (targetPos - spawnPos).normalized;
|
||||
Quaternion rotation = Quaternion.LookRotation(direction);
|
||||
GameObject proj = Instantiate(skill.Data.EffectPrefab, spawnPos, rotation);
|
||||
|
||||
// 투사체에 데미지 정보 전달
|
||||
// proj.GetComponent<Projectile>()?.Init(skill.CurrentLevelData.Damage * chargeRatio);
|
||||
}
|
||||
}
|
||||
|
||||
29
Assets/02_Scripts/Skill/Effects/ZoneEffect.cs
Normal file
29
Assets/02_Scripts/Skill/Effects/ZoneEffect.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ZoneEffect : MonoBehaviour, ISkillEffect
|
||||
{
|
||||
public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
{
|
||||
Vector3 center = caster.position + caster.forward * skill.CurrentLevelData.Range;
|
||||
SpawnZone(skill, center);
|
||||
}
|
||||
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos, float chargeRatio)
|
||||
{
|
||||
SpawnZone(skill, targetPos);
|
||||
}
|
||||
|
||||
private void SpawnZone(SkillInstance skill, Vector3 position)
|
||||
{
|
||||
if (skill.Data.ZonePrefab == null) return;
|
||||
|
||||
GameObject zoneObj = Instantiate(skill.Data.ZonePrefab, position, Quaternion.identity);
|
||||
ZoneEntity entity = zoneObj.GetComponent<ZoneEntity>();
|
||||
if (entity != null)
|
||||
{
|
||||
SkillLevelData data = skill.CurrentLevelData;
|
||||
float tickDmg = data.TickDamage > 0 ? data.TickDamage : data.Damage;
|
||||
entity.Init(tickDmg, data.Range, data.Duration, data.TickInterval, skill.Data.AppliedDebuffs);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Skill/Effects/ZoneEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/ZoneEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 681ba972155e69d4e903ca9f06ade300
|
||||
61
Assets/02_Scripts/Skill/Effects/ZoneEntity.cs
Normal file
61
Assets/02_Scripts/Skill/Effects/ZoneEntity.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ZoneEntity : MonoBehaviour
|
||||
{
|
||||
private float _damage;
|
||||
private float _radius;
|
||||
private float _duration;
|
||||
private float _tickInterval;
|
||||
private DebuffData[] _debuffs;
|
||||
|
||||
private float _lifeTimer;
|
||||
private float _tickAccumulator;
|
||||
|
||||
public void Init(float damage, float radius, float duration, float tickInterval, DebuffData[] debuffs)
|
||||
{
|
||||
_damage = damage;
|
||||
_radius = radius;
|
||||
_duration = duration;
|
||||
_tickInterval = tickInterval > 0 ? tickInterval : 1f;
|
||||
_debuffs = debuffs;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_lifeTimer += Time.deltaTime;
|
||||
_tickAccumulator += Time.deltaTime;
|
||||
|
||||
if (_tickAccumulator >= _tickInterval)
|
||||
{
|
||||
_tickAccumulator -= _tickInterval;
|
||||
ApplyTickDamage();
|
||||
}
|
||||
|
||||
if (_lifeTimer >= _duration)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyTickDamage()
|
||||
{
|
||||
Collider[] hits = Physics.OverlapSphere(transform.position, _radius);
|
||||
foreach (Collider col in hits)
|
||||
{
|
||||
IDamageable target = col.GetComponent<IDamageable>();
|
||||
if (target == null) continue;
|
||||
|
||||
target.TakeDamage(Mathf.RoundToInt(_damage), transform);
|
||||
|
||||
if (_debuffs != null)
|
||||
{
|
||||
StatusEffectReceiver receiver = col.GetComponent<StatusEffectReceiver>();
|
||||
if (receiver != null)
|
||||
{
|
||||
foreach (var debuff in _debuffs)
|
||||
receiver.ApplyDebuff(debuff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Skill/Effects/ZoneEntity.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/ZoneEntity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c474ebcf1164e1348b54f06b02241e08
|
||||
Reference in New Issue
Block a user