void UpdateActions()
    {
        if (ButtonDown(E_Input.Fire))
        {
            //fire only when there is no use
            if (Player.LocalInstance.InUseMode)
            {
                States.UseDelegate();
            }
            else
            {
                States.FireDownDelegate();
            }
        }

        if (ButtonUp(E_Input.Fire))
        {
            //delegate up event only for fire
            if (Player.LocalInstance.InUseMode == false)
            {
                States.FireUpDelegate();
            }
        }

        if (ButtonDown(E_Input.Reload) /* || Input.GetKeyDown("7")*/)         //JV FIX
        {
            States.ReloadDelegate();
        }

        if (ButtonDown(E_Input.Sprint))
        {
            States.SprintDownDelegate();
        }

        if (ButtonUp(E_Input.Sprint))
        {
            States.SprintUpDelegate();
        }

        if (ButtonDown(E_Input.Roll))
        {
            States.RollDelegate();
        }

        //FIX chyby na androidu - device obcas hlasi spatne escape stav kdyz delame multi touch
        bool escapeKeyPressed = Input.GetKeyUp("escape") && (Time.timeSinceLevelLoad > LastTouchControlTime + 0.25f);

        if ((ButtonDown(E_Input.Pause) || escapeKeyPressed))
        {
            if (MFGuiFader.Fading == false && GuiFrontendIngame.PauseMenuCooldown() == false)
            {
                GuiFrontendIngame.ShowPauseMenu();
            }
        }

        if (ButtonDown(E_Input.Item1))
        {
            ChangeItem(0);
        }
        else if (ButtonDown(E_Input.Item2))
        {
            ChangeItem(1);
        }
        else if (ButtonDown(E_Input.Item3))
        {
            ChangeItem(2);
        }

        if (ButtonDown(E_Input.Weapon1))
        {
            ChangeWeapon(0);
        }
        else if (ButtonDown(E_Input.Weapon2))
        {
            ChangeWeapon(1);
        }
        else if (ButtonDown(E_Input.Weapon3))
        {
            ChangeWeapon(2);
        }

        if (ButtonDown(E_Input.WeaponNext))
        {
            ChangeWeaponNext();
        }
        else if (ButtonDown(E_Input.WeaponPrev))
        {
            ChangeWeaponPrev();
        }

        /*if(ButtonDown(E_Input.Voicechat))
         * {
         *      if(Client.Instance)
         *              Client.Instance.SetVoiceChat(true);
         * }
         * else if (ButtonUp(E_Input.Voicechat))
         * {
         *      if(Client.Instance)
         *              Client.Instance.SetVoiceChat(false);
         * }*/
    }
Esempio n. 2
0
    bool ProcessKey(ref IInputEvent evt)
    {
        if (States.ActionsEnabled == false)
        {
            return(false);
        }

        if (Player.LocalInstance == null)
        {
            return(false);
        }

        KeyEvent key = (KeyEvent)evt;

        PlayerControlsGamepad.E_Input action = GetInputTableAction(key.Code);

        if (key.State == E_KeyState.Released)
        {
            // Escape and Tab are always hardcoded and can't be set by user
            switch (key.Code)
            {
            case KeyCode.Escape:
                if (MFGuiFader.Fading == false && GuiFrontendIngame.PauseMenuCooldown() == false)
                {
                    GuiFrontendIngame.ShowPauseMenu();
                }
                return(true);

            case KeyCode.Tab:
                GuiFrontendIngame.HideScoreMenu();
                return(true);
            }

            if (m_InputTable != null)
            {
                switch (action)
                {
                case PlayerControlsGamepad.E_Input.Fire:
                    Fire(false);
                    return(true);

                case PlayerControlsGamepad.E_Input.Sprint:
                    States.SprintUpDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Pause:
                    if (GuiHUD.Instance.CommandMenu != null && GuiHUD.Instance.CommandMenu.IsShown)
                    {
                        GuiHUD.Instance.CommandMenu.Hide();
                    }
                    return(true);
                }
                return(false);
            }

            switch (key.Code)
            {
            case KeyCode.RightControl:
            case KeyCode.LeftControl:
                Fire(false);
                return(true);

            case KeyCode.RightShift:
            case KeyCode.LeftShift:
                States.SprintUpDelegate();
                return(true);

            default:
                break;
            }
        }
        else if (key.State == E_KeyState.Pressed)
        {
            switch (key.Code)
            {
            case KeyCode.Return:
                //check for mouse lock unlock
                MouseCameraCtrl.SwitchCursor();
                return(true);

            case KeyCode.Tab:
                //E_MPGameType gameType = Client.Instance.GameState.GameType;
                GuiFrontendIngame.ShowScoreMenu(/*gameType, false*/);
                return(true);
            }

            if (m_InputTable != null)
            {
                switch (action)
                {
                case PlayerControlsGamepad.E_Input.Fire:
                    Fire(true);
                    return(true);

                case PlayerControlsGamepad.E_Input.Sprint:
                    States.SprintDownDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Roll:
                    States.RollDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Reload:
                    States.ReloadDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon1:
                    ChangeWeapon(0);
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon2:
                    ChangeWeapon(1);
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon3:
                    ChangeWeapon(2);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item1:
                    UseGadget(0);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item2:
                    UseGadget(1);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item3:
                    UseGadget(2);
                    return(true);

                case PlayerControlsGamepad.E_Input.WeaponNext:
                    ChangeWeaponNext();
                    return(true);

                case PlayerControlsGamepad.E_Input.WeaponPrev:
                    ChangeWeaponPrev();
                    return(true);

                case PlayerControlsGamepad.E_Input.Pause:
                    if (GuiHUD.Instance.CommandMenu != null && !m_IsFiring)
                    {
                        GuiHUD.Instance.CommandMenu.Show();
                        GuiHUD.Instance.CommandMenu.OpenMenu();
                    }
                    return(true);
                }
                return(false);
            }

            switch (key.Code)
            {
            case KeyCode.RightControl:
            case KeyCode.LeftControl:
                Fire(true);
                return(true);

            case KeyCode.RightShift:
            case KeyCode.LeftShift:
                States.SprintDownDelegate();
                return(true);

            case KeyCode.Space:
                States.RollDelegate();
                return(true);

            case KeyCode.R:
                States.ReloadDelegate();
                return(true);

            case KeyCode.Alpha1:
            case KeyCode.Keypad1:
                ChangeWeapon(0);
                return(true);

            case KeyCode.Alpha2:
            case KeyCode.Keypad2:
                ChangeWeapon(1);
                return(true);

            case KeyCode.Alpha3:
            case KeyCode.Keypad3:
                ChangeWeapon(2);
                return(true);

            case KeyCode.Alpha4:
            case KeyCode.Keypad4:
                ChangeWeapon(3);
                return(true);

            case KeyCode.Alpha7:
            case KeyCode.Keypad7:
                UseGadget(3);
                return(true);

            case KeyCode.Alpha8:
            case KeyCode.Keypad8:
            case KeyCode.H:
            case KeyCode.Q:
                UseGadget(2);
                return(true);

            case KeyCode.Alpha9:
            case KeyCode.Keypad9:
            case KeyCode.G:
            case KeyCode.E:
                UseGadget(1);
                return(true);

            case KeyCode.Alpha0:
            case KeyCode.Keypad0:
            case KeyCode.F:
                UseGadget(0);
                return(true);

            case KeyCode.O:
                SelectNextGadget();
                return(true);

            case KeyCode.I:
            case KeyCode.L:
                SelectPrevGadget();
                return(true);

            case KeyCode.P:
                UseSelectedGadget();
                return(true);

            default:
                break;
            }
        }

        return(false);
    }
Esempio n. 3
0
 void OnSprintDown()
 {
     States.SprintDownDelegate();
 }