Example #1
0
    //key bindings
    public void UseSkillAt(InputAction.CallbackContext ctx)
    {
        if (!m_PlayerStance.CanPerformAction(PlayerStance.Action.ACTION_CASTSPELL))
        {
            return;
        }

        ButtonControl button = ctx.control as ButtonControl;

        if (!button.wasPressedThisFrame)
        {
            return;
        }

        if (m_ItemSkillSlots.Count == 0)
        {
            return;
        }

        if (m_PlayerStance == null)
        {
            return;
        }

        SkillItem currentSkill = m_ItemSkillSlots.Peek();


        if (currentSkill.IsGroundOnlySpell())
        {
            if (!m_PlayerStance.CanPerformAction(PlayerStance.Action.ACTION_CASTSPELL))
            {
                return;
            }
        }

        // Player must draw his weapon before spell cast
        if (!m_PlayerStance.GetWeaponTransform().gameObject.activeInHierarchy)
        {
            return;
        }

        currentSkill.UseSkill(this.transform);
        m_CurrentActiveSkill = currentSkill.GetSkillType();
        m_CastInCurrentFrame = true;
        currentSkill.DecrementUses();


        if (currentSkill.HasNoMoreUses())
        {
            RemoveSkill();
        }
    }