Beispiel #1
0
        /// <summary>
        /// Check is character is able to cast a ability
        /// </summary>
        /// <param name="characterClass">Character class (attached to gameobject)</param>
        /// <param name="ability">Ability which is going to be cast</param>
        /// <returns></returns>
        private AbilityCastResult PerformAbilityValidation(ICharacterClass characterClass, IAbility ability)
        {
            AbilityCastResult abilityCastResult = BuildAbilityCastResult(PlayerOutputMessages.AbilityCastSuccessful, ability, AbilityResultState.ReadyToCast);

            if (characterClass.CheckIfEnoughMana(ability))
            {
                abilityCastResult = BuildAbilityCastResult(PlayerOutputMessages.NotEnoughMana, ability, AbilityResultState.NotEnoughMana);
            }

            if (characterClass.CheckIfEnoughStamina(ability))
            {
                abilityCastResult = BuildAbilityCastResult(PlayerOutputMessages.NotEnoughStamina, ability, AbilityResultState.NotEnoughStamina);
            }

            if (ability.OnCooldown)
            {
                abilityCastResult = BuildAbilityCastResult(PlayerOutputMessages.AbilityOnCooldown, ability, AbilityResultState.OnCooldown);
            }

            if (abilityCastResult.State != AbilityResultState.ReadyToCast)
            {
                errorMessageWindow.DisplayTextOnScreen(abilityCastResult.Message);
            }
            return(abilityCastResult);
        }