Add FlatStatModifier and PercentStatModifier classes; introduce Stat enum for character attributes
This commit is contained in:
69
Assets/Scripts/Modifiers/FlatStatModifier.cs
Normal file
69
Assets/Scripts/Modifiers/FlatStatModifier.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Data;
|
||||
using Interfaces;
|
||||
|
||||
namespace Modifiers
|
||||
{
|
||||
[Serializable]
|
||||
public class FlatStatModifier : IStatModifier
|
||||
{
|
||||
public Stat stat;
|
||||
public float value;
|
||||
public string Description => $"{stat} +{value}";
|
||||
|
||||
public void Apply(CharacterAttributes attributes)
|
||||
{
|
||||
ModifyAttributes(attributes, value);
|
||||
}
|
||||
|
||||
public void Remove(CharacterAttributes attributes)
|
||||
{
|
||||
Apply(attributes, -value);
|
||||
}
|
||||
|
||||
private void Apply(CharacterAttributes attributes, float value)
|
||||
{
|
||||
ModifyAttributes(attributes, value);
|
||||
}
|
||||
|
||||
private void ModifyAttributes(CharacterAttributes attributes, float value)
|
||||
{
|
||||
switch (stat)
|
||||
{
|
||||
case Stat.Health:
|
||||
attributes.ModifyHealth(value);
|
||||
break;
|
||||
case Stat.MaxHealth:
|
||||
attributes.ModifyMaxHealth(value);
|
||||
break;
|
||||
case Stat.MoveSpeed:
|
||||
attributes.ModifyMoveSpeed(value);
|
||||
break;
|
||||
case Stat.Luck:
|
||||
attributes.ModifyLuck(value);
|
||||
break;
|
||||
case Stat.Armor:
|
||||
attributes.ModifyArmor(value);
|
||||
break;
|
||||
case Stat.Damage:
|
||||
attributes.ModifyDamage(value);
|
||||
break;
|
||||
case Stat.RangedDamage:
|
||||
attributes.ModifyRangedDamage(value);
|
||||
break;
|
||||
case Stat.MeleeDamage:
|
||||
attributes.ModifyMeleeDamage(value);
|
||||
break;
|
||||
case Stat.AttackRange:
|
||||
attributes.ModifyAttackRange(value);
|
||||
break;
|
||||
case Stat.AttackSpeed:
|
||||
attributes.ModifyAttackSpeed(value);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user