コード例 #1
0
        public static void TakeHealing(this ICharacterClass characterClass, float healingTaken)
        {
            if (characterClass.CheckIfDead() == false)
            {
                float maximumHealth = characterClass.GetMaximumHealth();
                float currentHealth = characterClass.GetCurrentHealth();

                bool healingOverflow = currentHealth + healingTaken > maximumHealth;

                float validatedHealthValue = healingOverflow ? maximumHealth
                                                             : currentHealth + healingTaken;

                characterClass.SetCurrentHealth(validatedHealthValue);
                characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(healingTaken, StateValueChangeAction.TakingHealing);
            }
        }
コード例 #2
0
        public static void TakeDamage(this ICharacterClass characterClass, float damage)
        {
            if (characterClass.CheckIfDead() == false)
            {
                if (characterClass.CheckIfContainsCondition <DamageReduction>())
                {
                    Debug.Log("Hitting player on Damage reduction");
                }

                characterClass.SetCurrentHealth(characterClass.GetCurrentHealth() - damage);

                if (characterClass.CheckIfDead())
                {
                    if (OnPlayerDeath != null)
                    {
                        OnPlayerDeath.Invoke(characterClass);
                    }
                }

                characterClass.GetStatusBarManager().PerformValueChangeTextEffectWithColor(damage, StateValueChangeAction.TakingDamage);
            }
        }
コード例 #3
0
 private void RefreshPlayerStatusBar()
 {
     staminaBarFillImage.fillAmount = characterClass.GetCurrentStamina() / characterClass.GetMaximumStamina();
     manaBarFillImage.fillAmount    = characterClass.GetCurrentMana() / characterClass.GetMaximumMana();
     healthBarFillImage.fillAmount  = characterClass.GetCurrentHealth() / characterClass.GetMaximumHealth();
 }
コード例 #4
0
 public static bool CheckIfDead(this ICharacterClass characterClass)
 {
     return(characterClass.GetCurrentHealth() <= default(float));
 }