Example #1
0
        public virtual AbilityBehaviour AddAbilityBehaviorFromConfig(AbilityConfig _config, GameObject objectToattachTo)
        {
            AbilityBehaviour _behaviourComponent =
                _config.AddBehaviourComponent(objectToattachTo);

            _behaviourComponent.SetConfig(_config);
            return(_behaviourComponent);
        }
        public bool CanUseAbility(System.Type _type)
        {
            if (AllyStamina <= AllyMinStamina)
            {
                return(false);
            }
            AbilityConfig _config = GetAbilityConfig(_type);

            return(_config != null &&
                   AllyStamina >= _config.GetEnergyCost() &&
                   AbilityDictionary[_config].CanUseAbility());
        }
        public AbilityConfig GetAbilityConfig(int _index)
        {
            AbilityConfig _config = AbilityDictionary.Keys.ElementAt(_index);

            if (_config != null)
            {
                return(_config);
            }
            else
            {
                Debug.LogWarning($"Couldn't Find Ability Config at Index: {_index}");
                return(null);
            }
        }
        public virtual void AttemptSpecialAbility(AbilityConfig _config, AbilityBehaviour _behaviour, GameObject target = null)
        {
            var energyCost = _config.GetEnergyCost();

            if (energyCost <= AllyStamina)
            {
                if (_behaviour.CanUseAbility())
                {
                    ConsumeEnergy(energyCost);
                    _behaviour.Use(target);
                }
            }
            else
            {
                audioSource.PlayOneShot(outOfEnergy);
            }
        }
Example #5
0
 public virtual void SetConfig(AbilityConfig configToSet)
 {
     config = configToSet;
 }
 public AbilityBehaviour GetAbilityBehavior(AbilityConfig _config)
 {
     return(AbilityDictionary[_config]);
 }