コード例 #1
0
ファイル: Unit.cs プロジェクト: joshuaburton2/Kingsbane
    public void ModifyStat(StatModifierTypes modifierType, StatTypes statType, int value)
    {
        switch (modifierType)
        {
        case StatModifierTypes.Modify:
            var currentValue = Stats.Single(x => x.Type == statType).Value;
            ModifyStat(StatModifierTypes.Set, statType, currentValue + value);
            break;

        case StatModifierTypes.Set:
            Stats.Single(x => x.Type == statType).Value = value;
            break;

        default:
            throw new Exception("Not a valid modifier type");
        }
    }
コード例 #2
0
    public void AddStatModifier(Unit.StatTypes statType, StatModifierTypes modType, int value)
    {
        if (statType == Unit.StatTypes.Default || modType == StatModifierTypes.None)
        {
            throw new Exception("Not valid stat modifier inputs");
        }

        if (StatModifiers.Any(x => x.StatType == statType))
        {
            StatModifiers.RemoveAll(x => x.StatType == statType);
        }

        StatModifiers.Add(new StatModifier()
        {
            StatType = statType, ModType = modType, Value = value
        });
    }