public static void SubstractStamina(this ICharacterClass characterClass, float staminaPointsToSubstract) { float currentStamina = characterClass.GetCurrentStamina(); bool staminaLimitReached = currentStamina < currentStamina - staminaPointsToSubstract; float validatedStamina = staminaLimitReached ? default(float) : currentStamina - staminaPointsToSubstract; characterClass.SetCurrentStamina(validatedStamina); characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(staminaPointsToSubstract, StateValueChangeAction.ChangeStamina); }
public static void AddStamina(this ICharacterClass characterClass, float staminaPointsToAdd) { float currentStamina = characterClass.GetCurrentStamina(); float maximumStamina = characterClass.GetMaximumStamina(); bool staminaOverflow = currentStamina + staminaPointsToAdd > maximumStamina; float validatedStamina = staminaOverflow ? maximumStamina : currentStamina + staminaPointsToAdd; characterClass.SetCurrentStamina(validatedStamina); characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(staminaPointsToAdd, StateValueChangeAction.ChangeStamina); }
private void RefreshPlayerStatusBar() { staminaBarFillImage.fillAmount = characterClass.GetCurrentStamina() / characterClass.GetMaximumStamina(); manaBarFillImage.fillAmount = characterClass.GetCurrentMana() / characterClass.GetMaximumMana(); healthBarFillImage.fillAmount = characterClass.GetCurrentHealth() / characterClass.GetMaximumHealth(); }
public static bool CheckIfEnoughStamina(this ICharacterClass characterClass, IAbility ability) { return(characterClass.GetCurrentStamina() < ability.StaminaCost); }