public static void SubstractMana(this ICharacterClass characterClass, float manaPointsToSubstract)
        {
            float currentMana      = characterClass.GetCurrentMana();
            bool  manaLimitReached = currentMana < currentMana - manaPointsToSubstract;

            float validatedMana = manaLimitReached ? default(float)
                                                   : currentMana - manaPointsToSubstract;

            characterClass.SetCurrentMana(validatedMana);
            characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(manaPointsToSubstract, StateValueChangeAction.ChangeMana);
        }
        public static void AddMana(this ICharacterClass characterClass, float manaPointsToAdd)
        {
            float currentMana = characterClass.GetCurrentMana();
            float maximumMana = characterClass.GetMaximumMana();

            bool manaOverflow = currentMana + manaPointsToAdd > maximumMana;

            float validatedMana = manaOverflow ? maximumMana
                                               : currentMana + manaPointsToAdd;

            characterClass.SetCurrentMana(validatedMana);
            characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(manaPointsToAdd, StateValueChangeAction.ChangeMana);
        }
Esempio n. 3
0
 private void RefreshPlayerStatusBar()
 {
     staminaBarFillImage.fillAmount = characterClass.GetCurrentStamina() / characterClass.GetMaximumStamina();
     manaBarFillImage.fillAmount    = characterClass.GetCurrentMana() / characterClass.GetMaximumMana();
     healthBarFillImage.fillAmount  = characterClass.GetCurrentHealth() / characterClass.GetMaximumHealth();
 }
 public static bool CheckIfEnoughMana(this ICharacterClass characterClass, IAbility ability)
 {
     return(characterClass.GetCurrentMana() < ability.ManaCost);
 }