コード例 #1
0
    private void OnSkillHotkeyImplementation(SkillCastEvent skillCast)
    {
        PlayerSkillVO skillVO;

        if (skillCast.IsWeaponSkill)
        {
            if (m_SkillProxy.UsingReformer())
            {
                skillVO = m_SkillProxy.GetReformerSkill();
            }
            else
            {
                skillVO = m_SkillProxy.GetCurrentWeaponSkill();
                if (skillVO != null && !m_CfgSkillProxy.IsWeaponSkill(skillVO.GetID()))
                {
                    Debug.LogErrorFormat("技能 {0} 被配置在武器上, 但它并不是一个武器技能! 找策划确认一下技能表和武器表", skillVO.GetID());
                }
            }
        }
        else
        {
            skillVO = m_SkillProxy.GetSkillByIndex(skillCast.SkillIndex);
            if (skillVO != null && m_CfgSkillProxy.IsWeaponSkill(skillVO.GetID()))
            {
                Debug.LogErrorFormat("技能 {0} 被配置在飞船上, 但它其实是一个武器技能! 找策划确认一下技能表和武器表", skillVO.GetID());
            }
        }

        if (skillVO != null)
        {
            int skillID = skillVO.GetID();

            bool keyPressed = skillCast.KeyPressed;

            if (keyPressed && !IsReleasingSkill(skillID))
            {
                // 释放Trigger技能的过程中, 可以释放非Trigger技能. 此时Trigger技能中断, 等非Trigger技能结束后继续放
                // 不是Trigger技能的话, 每次技能按键按下, 只能释放一次
                if ((m_CfgSkillProxy.IsTriggerSkill(skillID) && !OneOfReleasingSkillsIsNotTriggerSkill()) ||
                    (!m_CfgSkillProxy.IsTriggerSkill(skillID) && !SkillHasReleasedDuringPress(skillID)))
                {
                    ReleaseSkillByClientInput(skillID);
                    SetSkillReleaseDuringPress(skillID, true);

                    if (m_CfgSkillProxy.IsTriggerSkill(skillID))
                    {
                        m_Property.SetTriggerSkillID(skillID);
                        m_Property.SetReleasingTriggerSkill(true);
                    }
                }
            }
            else
            {
                SkillControlEvent skillEvent = keyPressed ? SkillControlEvent.Event_SkillButtonPress : SkillControlEvent.Event_SkillButtonRelease;
                SendEventToSkill(skillID, skillEvent, null);

                if (!keyPressed)
                {
                    SetSkillReleaseDuringPress(skillID, false);
                    m_Property.SetReleasingTriggerSkill(false);
                    m_Property.SetTriggerSkillID(-1);
                }
            }
        }
    }