Exemplo n.º 1
0
    float GetClampedForceToApply(float forceAddedMagnitudeClamped)
    {
        float staminaPercUsed = forceAddedMagnitudeClamped / differenceTotalForce;
        float oldStaminaCache = staminaBar.GetPercentStamina();
        float newStaminaPerc  = Mathf.Clamp(oldStaminaCache - staminaPercUsed, 0, 1);

        staminaBar.SetPercentStamina(newStaminaPerc);
        staminaBar.SetCurrentStamina(staminaBar.GetMaxStamina() * newStaminaPerc);

        float forceCalculationWithCurrentStamina = Mathf.Clamp(oldStaminaCache * differenceTotalForce, minForceToApply, forceAddedMagnitudeClamped);

        return(forceCalculationWithCurrentStamina);
    }