25 lines
661 B
C#
25 lines
661 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Attribute : ScriptableObject
|
|
{
|
|
public long Base { get; set; }
|
|
|
|
/// <summary>
|
|
/// Calculates the stat value with accumulated buff and debuff modifiers.
|
|
/// </summary>
|
|
/// <returns>(base + baseBonus) * (100% + permyriadBonus) + flatBonus, bounded below by 0.</returns>
|
|
public long Calc(EffectSO effect)
|
|
{
|
|
var r = Base + effect.Base;
|
|
var m = effect.Permyriad + 10000;
|
|
r = r * (m / 10000) + (r / 10000) * (m % 10000) + effect.Flat;
|
|
if (r <= 0)
|
|
{
|
|
return 0;
|
|
}
|
|
return r;
|
|
}
|
|
}
|