Files
Genesis_Unity/Assets/02_Scripts/Skill/SkillInstance.cs

35 lines
919 B
C#

public class SkillInstance : IUseableRuntime
{
public SkillData Data { get; private set; }
public int Level { get; set; } = 1;
public float CooldownTimer { get; set; }
public bool IsOnCooldown => CooldownTimer > 0f;
public SkillLevelData CurrentLevelData => Data.GetLevelData(Level);
public SkillInstance(SkillData data, int level = 1)
{
Data = data;
Level = level;
}
public void StartCooldown()
{
CooldownTimer = CurrentLevelData.Cooldown;
}
public void TickCooldown(float deltaTime)
{
if (CooldownTimer > 0f)
CooldownTimer -= deltaTime;
}
public void Execute(UseContext ctx)
{
SkillModule skillModule = ctx.Caster.GetComponent<SkillModule>(); //사용자(캐스터)의 스킬 모듈
if (skillModule == null) return;
skillModule.SkillInputByData(Data, ctx.UseInputState);
}
}