public override void WeaponOperationImplementation(SkillHotkey skillHotkey)
    {
        // if current state is idle.
        //		hotkey pressed, start to lock
        // if current state is lock.
        //		hotkey released and there are more than one target we have locked, start to attack. else set state to idle

        bool cast = skillHotkey.ActionPhase == HotkeyPhase.Started;

        switch (m_State)
        {
        case State.Idle:
            if (cast && CanWeaponFire())
            {
                SLog("进入锁定状态");
                // 导弹技能冷却以后才能发射
                m_State = State.Lock;
                m_LockTargeMap.Clear();
                m_MainPlayer.SetCanToggleWeapon(false);
                NetworkManager.Instance.GetSkillController().SendMissileLockTarget(true);
            }
            break;

        case State.Lock:
            if (!cast)
            {
                SLog("松开武器按键");
                if (ExistingLockedTarget() && m_PlayerSkillProxy.CanCurrentWeaponRelease())
                {
                    SLog("有锁定目标, 进入攻击状态, 释放技能");
                    m_State = State.Attack;
                    CastSkill();
                }
                else if (ExistingLockedTarget() && !m_PlayerSkillProxy.CanCurrentWeaponRelease())
                {
                    GameFacade.Instance.SendNotification(NotificationName.PlayerWeaponFireFail);
                }
                else
                {
                    SLog("没有锁定目标, 结束这次攻击流程");
                    ResetWeaponRuntimeData();
                }

                NetworkManager.Instance.GetSkillController().SendMissileLockTarget(false);
            }
            break;

        case State.Attack:
            // 导弹正在依次发射的过程中, 按下鼠标左键, 不可以进入锁定状态. By 刘斌 (暂定)
            break;

        default:
            break;
        }
    }
    /// <summary>
    /// 操作武器的处理. 有些武器不是按下就释放技能的, 比如导弹. 所以在这里包一层
    /// </summary>
    /// <param name="hotkey"></param>
    public void WeaponOperation(SkillHotkey skillHotkey)
    {
        bool press = skillHotkey.ActionPhase == HotkeyPhase.Started;

        // 解决快捷键响应方式改变的问题
        m_SkillCastEvent = skillHotkey;
        // 武器技能的持续释放才在这里模拟, 否则在技能组件里模拟
        m_SkillKeyPressed = press && m_SkillCastEvent.IsWeaponSkill;

        WeaponOperationByHotKey(skillHotkey);
    }
    /// <summary>
    /// 机枪武器对应的技能是一个持续引导技能, 按键按下后, 在松开之前, 只记做一次技能发射
    /// </summary>
    /// <param name="hotkey"></param>
    public override void WeaponOperationImplementation(SkillHotkey skillHotkey)
    {
        bool press = skillHotkey.ActionPhase == HotkeyPhase.Started;

        if (press)
        {
            if (!m_FiredDuringThisPress && m_PlayerSkillProxy.CanCurrentWeaponRelease())
            {
                SkillCastEvent castSkillEvent = new SkillCastEvent();
                castSkillEvent.IsWeaponSkill = true;
                castSkillEvent.SkillIndex    = skillHotkey.SkillIndex;
                castSkillEvent.KeyPressed    = true;

// #if NewSkill
// #else
                m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent);
//#endif

                m_FiredDuringThisPress = true;
                m_State           = GunState.Fire;
                m_TimeOfStartFire = Time.time;
            }
            else if (!m_FiredDuringThisPress && !m_PlayerSkillProxy.CanCurrentWeaponRelease())
            {
                GameFacade.Instance.SendNotification(NotificationName.PlayerWeaponFireFail);
            }
            else
            {
                // 已经放过技能了, 不再发送释放技能消息. 解决武器过热以后还会继续射击的问题
            }
        }
        else
        {
            if (m_State == GunState.Fire)
            {
                SkillCastEvent castSkillEvent = new SkillCastEvent();
                castSkillEvent.IsWeaponSkill = true;
                castSkillEvent.SkillIndex    = skillHotkey.SkillIndex;
                castSkillEvent.KeyPressed    = false;

// #if NewSkill
// #else
                m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent);
//#endif

                m_FiredDuringThisPress = false;
                m_State                   = GunState.Stop;
                m_TimeOfStopFire          = Time.time;
                m_BulletCountWhenStopFire = m_CurrentBulletCount;
            }
        }
    }
Beispiel #4
0
    /// <summary>
    /// 武器响应按键
    /// </summary>
    /// <param name="skillHotkey"></param>
    public void OnHotKey(SkillHotkey skillHotkey)
    {
        // Leyoutech.Utility.DebugUtility.Log("武器", "准星---OnHotKey--> 状态" + skillHotkey.ActionPhase);

        bool press = skillHotkey.ActionPhase == HotkeyPhase.Started;

        if (press && IsCanRelease())
        {
            OnHotKeyDown((int)m_SkillID);
        }
        else
        {
            OnHotKeyUp((int)m_SkillID);
        }
    }
Beispiel #5
0
    public void OnWeaponFire(HotkeyCallback callbackContext)
    {
        if (m_SpacecraftInputProperty.GetMotionType() == MotionType.Mmo ||
            m_SpacecraftInputProperty.GetMotionType() == MotionType.Dof4)
        {
            if (callbackContext.started && !m_BurstReadyPressed && (Time.time - m_BurstReadyReleaseTime > 0.1f))
            {
                if (m_SpacecraftInputProperty.GetCurrentState().GetMainState() == EnumMainState.Cruise)
                {
                    RpcChangeState(StateActionOpType.PutIntoGearFighting);
                }
            }
        }

        LeftClickIsState    = callbackContext.phase == HotkeyPhase.Started;
        LeftClickActionName = callbackContext.action.name;

        if (!m_BurstReadyPressed && !LeftClickIsState)
        {
            // Leyoutech.Utility.DebugUtility.Log("武器", "Input 热键抬起,请求释放技能结束");

            SkillHotkey skillKey = new SkillHotkey();
            skillKey.Hotkey        = callbackContext.action.name;
            skillKey.IsWeaponSkill = true;
            skillKey.ActionPhase   = callbackContext.phase;

            SendEvent(ComponentEventName.WeaponOperation, skillKey);

            LeftClickIsState    = false;
            LeftClickActionName = string.Empty;
            OldLeftClickIsState = false;
        }
        else
        {
            // InputSystem中一个实体按键不能同时设置到两个不同的Action中.
            // 所以把开火和激活Burst模式都放到武器开火的Action中处理.
            if (m_SpacecraftInputProperty.GetBurstReady() &&
                m_SpacecraftInputProperty.GetCurrentState().GetMainState() == EnumMainState.Fight &&
                !m_SpacecraftInputProperty.GetCurrentState().IsHasSubState(EnumSubState.Peerless) &&
                callbackContext.performed)
            {
                if (m_SpacecraftInputProperty.GetAttribute(AttributeName.kConverterValue) >= m_SpacecraftInputProperty.GetAttribute(AttributeName.kConverterMax))
                {
                    RpcChangeState(StateActionOpType.PutIntoGearPeerLess);
                }
            }
        }
    }
Beispiel #6
0
    private void WeaponFireUpdate()
    {
        if (!m_BurstReadyPressed &&
            m_SpacecraftInputProperty.GetCurrentState().GetMainState() == EnumMainState.Fight &&
            LeftClickIsState &&
            !OldLeftClickIsState)
        {
            // Leyoutech.Utility.DebugUtility.Log("武器", "input 热键按下,请求释放技能");

            OldLeftClickIsState = LeftClickIsState;
            SkillHotkey skillKey = new SkillHotkey();
            skillKey.Hotkey        = LeftClickActionName;
            skillKey.IsWeaponSkill = true;
            skillKey.ActionPhase   = HotkeyPhase.Started;
            SendEvent(ComponentEventName.WeaponOperation, skillKey);
        }
    }
    /// <summary>
    /// 武器热键响应
    /// </summary>
    private void WeaponHotKeyOperation(IComponentEvent entityEvent)
    {
        SkillHotkey skillHotkey = entityEvent as SkillHotkey;
        IWeapon     weapon      = m_SkillProxy.GetCurrentWeapon();

        if (weapon == null)
        {
            return;
        }

        //武器&准星循环
        WeaponAndCrossSight weaponCS = m_SkillProxy.GetCurrentWeaponAndCrossSight();

        if (weaponCS != null)
        {
            weaponCS.OnHotKey(skillHotkey);
        }
    }
    public virtual void WeaponOperationImplementation(SkillHotkey skillHotkey)
    {
        bool press = skillHotkey.ActionPhase == HotkeyPhase.Started;

        if (m_PlayerSkillProxy.CanCurrentWeaponRelease() || !press)
        {
            SkillCastEvent castSkillEvent = new SkillCastEvent();
            castSkillEvent.IsWeaponSkill = true;
            castSkillEvent.SkillIndex    = skillHotkey.SkillIndex;
            castSkillEvent.KeyPressed    = press;

            m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent);
        }

        if (!m_PlayerSkillProxy.CanCurrentWeaponRelease())
        {
            GameFacade.Instance.SendNotification(NotificationName.PlayerWeaponFireFail);
        }
    }
    public void WeaponOperationByHotKey(SkillHotkey skillHotkey)
    {
        if (m_PlayerSkillProxy.UsingReformer())
        {
            SkillCastEvent castSkillEvent = new SkillCastEvent();
            castSkillEvent.IsWeaponSkill = true;
            castSkillEvent.SkillIndex    = skillHotkey.SkillIndex;
            castSkillEvent.KeyPressed    = skillHotkey.ActionPhase == HotkeyPhase.Started;

//#if NewSkill
//#else
            m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent);
//#endif
        }
        else
        {
            WeaponOperationImplementation(skillHotkey);
        }
    }
Beispiel #10
0
    private void OnWeaponOperation(IComponentEvent entityEvent)
    {
        SkillHotkey skillHotkey = entityEvent as SkillHotkey;

        IWeapon weapon = m_SkillProxy.GetCurrentWeapon();

        if (weapon == null)
        {
            return;
        }

        // 获取iWeapon对应武器的UID
        ulong            uid          = weapon.GetUID();
        BattleWeaponBase battleWeapon = m_Property.GetBattleWeapon(uid);

        if (battleWeapon != null)
        {
            battleWeapon.WeaponOperation(skillHotkey);
        }
    }