Esempio n. 1
0
    private void CastSpell(int spellIndex)
    {
        Aim();
        StopAim();
        ActorAttack.EnsureStopSecondaryMode();
        DevSpell spell = Content.Instance.GetSpellAtIndex(spellIndex);

        if (spell == null)
        {
            return;
        }

        if (LocalUserInfo.Me.ClientCharacter.CurrentPrimaryAbility.LVL < spell.Level)
        {
            return;
        }

        bool usedSpell = LocalUserInfo.Me.ClientCharacter.SpellsCooldowns.AttemptUseSpell(spell);

        if (usedSpell)
        {
            usedSpell = ManaUsage.Instance.UseMana(spell.Mana);
        }
        if (usedSpell)
        {
            InGameMainMenuUI.Instance.ActivatedSpell(spell.Key);

            if (spell.spellTypeEnumState == SpellTypeEnumState.movement)
            {
                ExecuteMovementSpell(spell);
            }

            AttackIdCounter++;
            CurrentSpellAttackId = AttackIdCounter;
            CurrentSpellInCast   = spell;

            LocalUserInfo.Me.ClientCharacter.SpellsCooldowns.UseSpell(spell);
            SocketClient.Instance.SendUsedSpell(spell.Key, CurrentSpellAttackId);

            Instance.CastSpell(spell);
        }
    }