Ejemplo n.º 1
0
        /// <summary>
        /// Adds an ability to the active ability list.
        /// If an ability is already active then that ability duration is restored
        /// </summary>
        /// <param name="eve"></param>
        private void OnAbilityGranted(GrantAbilityEvent eve)
        {
            PlayerAbility ability = null;

            if (IsAbilityGranted(eve.abilityType))
            {
                switch (eve.abilityType)
                {
                case PlayerAbilityType.SpeedMultiplier:
                    ability = gameObject.GetComponent <SpeedMultiplierAbility>();
                    break;

                case PlayerAbilityType.DoubleJump:
                    ability = gameObject.GetComponent <DoubleJumpAbility>();
                    break;

                case PlayerAbilityType.Invincibility:
                    ability = gameObject.GetComponent <InvincibilityAbility>();
                    break;
                }

                ability.RestoreTheAbilityDuration();
            }
            else
            {
                switch (eve.abilityType)
                {
                case PlayerAbilityType.SpeedMultiplier:
                    ability = gameObject.AddComponent <SpeedMultiplierAbility>();
                    break;

                case PlayerAbilityType.DoubleJump:
                    ability = gameObject.AddComponent <DoubleJumpAbility>();
                    break;

                case PlayerAbilityType.Invincibility:
                    ability = gameObject.AddComponent <InvincibilityAbility>();
                    break;
                }
                ability.InitializeAbility(abilityConfig);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Add the ability in the UI
 /// </summary>
 /// <param name="e"></param>
 private void OnAbilityGranted(GrantAbilityEvent e)
 {
     abilityTrayUI.AddNewAbility(e.abilityType);
 }