Esempio n. 1
0
        public void CastAbility(KeyCode key, LayerMask collisionLayer)
        {
            AbilityCooldownDisplay abilitySlot = abilitySlots[key];

            if (abilitySlot.ability == null)
            {
                return;
            }
            if (!abilitySlot.CooldownReady())
            {
                return;
            }

            castedAbility = abilitySlot.ability;
            Vector3 lookPoint = PlayerInfo.GetPlayerCursor().Position;

            //prepare cast and check if its valid
            abilitySlot.ability.PrepareCast(lookPoint, gameObject, castPosition, collisionLayer);
            if (!abilitySlot.ability.CastIsValid(gameObject))
            {
                return;
            }

            //cast and set cooldown
            if (!scheduler.StartAction(this, true))
            {
                return;
            }
            abilitySlot.SetCooldown();
            if (abilitySlot.ability.shouldRotate)
            {
                RotateCharacter(lookPoint);
            }
            if (abilitySlot.ability.castImmediately)
            {
                abilitySlot.ability.CastAction();
            }

            if (abilitySlot.ability.animationClip == null)
            {
                FinishedCast();
                return;
            }

            //handle animation
            animator.SetTrigger("cast");
            animator.SetTrigger("cast" + abilitySlot.index);

            /* ability cast is triggert by animation event CastAction() */
        }
Esempio n. 2
0
        public void SetNewAbility(AbilityGem gem, AbilityCooldownDisplay slot)
        {
            if (gem == null)
            {
                slot.SetAbility(null);
                return;
            }
            Ability abilityInstance = InstanciateAbility(gem.ability);

            slot.SetAbility(abilityInstance);

            abilityInstance.baseEffectValue = gem.baseEffectValue;
            abilityInstance.range           = gem.ability.range;
            if (animator == null)
            {
                animator = GetComponentInChildren <Animator>();
            }
            AnimationHandler.OverrideAnimations(animator, gem.ability.animationClip, "Cast" + slot.index);
        }