hellbound/Assets/Scripts/Game/Buffs/Buff.cs

46 lines
1.0 KiB
C#
Raw Permalink Normal View History

2021-11-26 11:16:25 +03:00
using System;
using game;
using UnityEngine;
public class Buff
{
public readonly EnumBuffType Type;
public readonly string Title;
public readonly Sprite Icon;
private readonly ConfBuffProgression _progression;
public int MaxLevel => _progression.levels.Count;
public ConfBuffLevel GetLevelInfo(int level = -1)
{
if (level == -1)
level = GetCurrentLevel();
level = Math.Min(level, _progression.levels.Count);
if (level - 1 < 0)
level = 1;
return _progression.levels[level - 1];
}
public bool CanUpgrade()
{
return GetCurrentLevel() < _progression.levels.Count;
}
public int GetCurrentLevel()
{
return Save.Buffs.GetLevel(Type);
}
public Buff(ConfBuff config)
{
Type = config.buffType;
Title = config.view.title;
Icon = string.IsNullOrEmpty(config.view.icon)
? null : Assets.Load<Sprite>(config.view.icon);
_progression = config.progression;
}
}