2026-04-08 스킬시스템 진행중, 폴더구조 변경등

This commit is contained in:
2026-04-08 05:36:01 +09:00
parent 0844a07902
commit 4eca51b885
1334 changed files with 61947 additions and 14859 deletions

View File

@@ -0,0 +1,55 @@
using UnityEngine;
public class DebuffInstance
{
public DebuffData Data { get; private set; }
public float RemainingTime { get; private set; }
public bool IsExpired => RemainingTime <= 0f;
private StatusEffectReceiver _receiver;
private float _tickAccumulator;
private GameObject _visualInstance;
public DebuffInstance(DebuffData data, StatusEffectReceiver receiver)
{
Data = data;
_receiver = receiver;
RemainingTime = data.Duration;
_tickAccumulator = 0f;
}
public void OnApply()
{
if (Data.EffectPrefab != null)
{
_visualInstance = Object.Instantiate(Data.EffectPrefab, _receiver.transform);
}
}
public void Tick(float deltaTime)
{
RemainingTime -= deltaTime;
if (Data.DebuffType == DebuffType.DamageOverTime && Data.TickInterval > 0)
{
_tickAccumulator += deltaTime;
if (_tickAccumulator >= Data.TickInterval)
{
_tickAccumulator -= Data.TickInterval;
IDamageable damageable = _receiver.GetComponent<IDamageable>();
damageable?.TakeDamage(Mathf.RoundToInt(Data.Value), null);
}
}
}
public void OnRemove()
{
if (_visualInstance != null)
Object.Destroy(_visualInstance);
}
public void RefreshDuration()
{
RemainingTime = Data.Duration;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 17e97bf635cef364781fdf5cedc5dfee

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public interface IDamageable
{
void TakeDamage(int damage, Transform source);
Transform GetTransform();
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cd29cb0b94cdd2c4388ff287969a9b5e

View File

@@ -0,0 +1,69 @@
using System.Collections.Generic;
using UnityEngine;
public class StatusEffectReceiver : MonoBehaviour
{
private List<DebuffInstance> _activeDebuffs = new List<DebuffInstance>();
public void ApplyDebuff(DebuffData data)
{
if (data == null) return;
if (!data.Stackable)
{
DebuffInstance existing = _activeDebuffs.Find(d => d.Data == data);
if (existing != null)
{
existing.RefreshDuration();
return;
}
}
else
{
int count = 0;
foreach (var d in _activeDebuffs)
if (d.Data == data) count++;
if (count >= data.MaxStacks) return;
}
DebuffInstance instance = new DebuffInstance(data, this);
_activeDebuffs.Add(instance);
instance.OnApply();
}
private void Update()
{
for (int i = _activeDebuffs.Count - 1; i >= 0; i--)
{
_activeDebuffs[i].Tick(Time.deltaTime);
if (_activeDebuffs[i].IsExpired)
{
_activeDebuffs[i].OnRemove();
_activeDebuffs.RemoveAt(i);
}
}
}
public bool HasDebuff(DebuffType type)
{
foreach (var d in _activeDebuffs)
if (d.Data.DebuffType == type) return true;
return false;
}
public float GetDebuffValue(DebuffType type)
{
float total = 0f;
foreach (var d in _activeDebuffs)
if (d.Data.DebuffType == type) total += d.Data.Value;
return total;
}
public void ClearAllDebuffs()
{
for (int i = _activeDebuffs.Count - 1; i >= 0; i--)
_activeDebuffs[i].OnRemove();
_activeDebuffs.Clear();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dafab9c2111f5d640bf9eb470963b85d