public override void BuffValue(BuffableValue buffType, ref float buffedValue) { if (buffType == BuffableValue.PercentDamageReceived) { buffedValue *= Description.Amount; } }
public override void BuffValue(BuffableValue buffType, ref float buffedValue) { if (buffType == BuffableValue.PercentDamageReceived) { float timeSpentChargingUp = m_StoppedChargingUpTime - TimeStarted; float pctChargedUp = Mathf.Clamp01(timeSpentChargingUp / Description.ExecTimeSeconds); // the amount of damage reduction starts at 50% (for not-charged-up), then slowly increases to 100% depending on how charged-up we got float pctDamageReduction = 0.5f + ((pctChargedUp * pctChargedUp) / 2); // Now that we know how much damage to reduce it by, we need to set buffedValue to the inverse (because // it's looking for how much damage to DO, not how much to REDUCE BY). Also note how we don't just SET // buffedValue... we multiply our buff in with the current value. This lets our Action "stack" // with any other Actions that also alter this variable.) buffedValue *= 1 - pctDamageReduction; } else if (buffType == BuffableValue.ChanceToStunTramplers) { // if we are at "full charge", we stun enemies that try to trample us! float timeSpentChargingUp = m_StoppedChargingUpTime - TimeStarted; if (timeSpentChargingUp / Description.ExecTimeSeconds >= 1 && buffedValue < 1) { buffedValue = 1; } } }
/// <summary> /// Called on all active Actions to give them a chance to alter the outcome of a gameplay calculation. Note /// that this is used for both "buffs" (positive gameplay benefits) and "debuffs" (gameplay penalties). /// </summary> /// <remarks> /// In a more complex game with lots of buffs and debuffs, this function might be replaced by a separate /// BuffRegistry component. This would let you add fancier features, such as defining which effects /// "stack" with other ones, and could provide a UI that lists which are affecting each character /// and for how long. /// </remarks> /// <param name="buffType">Which gameplay variable being calculated</param> /// <param name="orgValue">The original ("un-buffed") value</param> /// <param name="buffedValue">The final ("buffed") value</param> public virtual void BuffValue(BuffableValue buffType, ref float buffedValue) { }