52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
|
using System;
|
|||
|
using game;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace RND
|
|||
|
{
|
|||
|
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|