Hi, I have a question, I made this class:
public class BonusMaxValue {
[SerializeField] float _maxValue = 0;
protected float bonus = 0;
public float maxValue { get { return _maxValue + bonus; } }
public Action<float> OnMaxValueBonusChanged;
public void SetBonus(float amount)
{
bonus = amount;
OnMaxValueBonusChanged?.Invoke(amount);
}
public void AddBonus(float amount)
{
bonus += amount;
OnMaxValueBonusChanged?.Invoke(amount);
}
public void RemoveBonus(float amount)
{
bonus -= amount;
OnMaxValueBonusChanged?.Invoke(amount);
}
public void AddMultiplierBonus(float multiplier)
{
float amount = (_maxValue * multiplier) - _maxValue;
bonus += amount;
OnMaxValueBonusChanged?.Invoke(amount);
}
public void RemoveMultiplierBonus(float multiplier)
{
float amount = (_maxValue * multiplier) - _maxValue;
bonus -= amount;
OnMaxValueBonusChanged?.Invoke(amount);
}
}
and I would like to multiply this classe by another or by a float to get the multiplication of the float and the maxValue. I saw in unity this line of code for Vector3 class:
public static Vector3 operator *(float d, Vector3 a);
So I think, it’s possible to do it but I don’t know how does it work.