コード例 #1
0
    public PlayerAction SendAction()
    {
        List <int> actionKeys = new List <int>();

        for (int i = 0; i < moveList.Length; i++)
        {
            if (PlayerManager.LocalPlayer == gameObject && UIManager.IsInputFocus)
            {
                return(new PlayerAction {
                    moveActions = actionKeys.ToArray()
                });
            }

            // if (CommonInput.GetKey(moveList[i]) && allowInput)
            // {
            //  actionKeys.Add((int)moveList[i]);
            // }
            if (KeyboardInputManager.CheckMoveAction(moveList[i]) && allowInput)
            {
                actionKeys.Add((int)moveList[i]);
            }
        }

        return(new PlayerAction {
            moveActions = actionKeys.ToArray()
        });
    }
コード例 #2
0
ファイル: PlayerManager.cs プロジェクト: fomalsd/unitystation
    /// <summary>
    /// Processes currenlty held directional movement keys into a PlayerAction.
    /// Opposite moves on the X or Y axis cancel out, not moving the player in that axis.
    /// Moving while dead spawns the player's ghost.
    /// </summary>
    /// <returns> A PlayerAction containing up to two (non-opposite) movement directions.</returns>
    public PlayerAction GetMovementActions()
    {
        // Stores the directions the player will move in.
        List <int> actionKeys = new List <int>();

        // Only move if player is out of UI
        if (!(LocalPlayer == gameObject && UIManager.IsInputFocus))
        {
            bool moveL = KeyboardInputManager.CheckMoveAction(MoveAction.MoveLeft);
            bool moveR = KeyboardInputManager.CheckMoveAction(MoveAction.MoveRight);
            bool moveU = KeyboardInputManager.CheckMoveAction(MoveAction.MoveDown);
            bool moveD = KeyboardInputManager.CheckMoveAction(MoveAction.MoveUp);
            // Determine movement on each axis (cancelling opposite moves)
            int moveX = (moveR ? 1 : 0) - (moveL ? 1 : 0);
            int moveY = (moveD ? 1 : 0) - (moveU ? 1 : 0);

            if (moveX != 0 || moveY != 0)
            {
                switch (moveX)
                {
                case 1:
                    actionKeys.Add((int)MoveAction.MoveRight);
                    break;

                case -1:
                    actionKeys.Add((int)MoveAction.MoveLeft);
                    break;

                default:
                    break;                                     // Left, Right cancelled or not pressed
                }
                switch (moveY)
                {
                case 1:
                    actionKeys.Add((int)MoveAction.MoveUp);
                    break;

                case -1:
                    actionKeys.Add((int)MoveAction.MoveDown);
                    break;

                default:
                    break;                                     // Up, Down cancelled or not pressed
                }
            }
        }

        return(new PlayerAction {
            moveActions = actionKeys.ToArray()
        });
    }
コード例 #3
0
    public PlayerAction SendAction()
    {
        List <int> actionKeys = new List <int>();

        for (int i = 0; i < moveList.Length; i++)
        {
            if (PlayerManager.LocalPlayer == gameObject && UIManager.IsInputFocus)
            {
                return(new PlayerAction {
                    moveActions = actionKeys.ToArray()
                });
            }

            // if (CommonInput.GetKey(moveList[i]) && allowInput)
            // {
            //  actionKeys.Add((int)moveList[i]);
            // }
            if (KeyboardInputManager.CheckMoveAction(moveList[i]))
            {
                if (allowInput && !IsBuckled && !IsCuffed)
                {
                    actionKeys.Add((int)moveList[i]);
                }
                else
                {
                    var LHB = GetComponent <LivingHealthBehaviour>();
                    if (LHB.IsDead)
                    {
                        pna.CmdSpawnPlayerGhost();
                    }
                }
            }
        }

        return(new PlayerAction {
            moveActions = actionKeys.ToArray()
        });
    }
コード例 #4
0
    public PlayerAction SendAction()
    {
        List <int> actionKeys = new List <int>();

        for (int i = 0; i < moveList.Length; i++)
        {
            if (PlayerManager.LocalPlayer == gameObject && UIManager.IsInputFocus)
            {
                return(new PlayerAction {
                    moveActions = actionKeys.ToArray()
                });
            }

            // If player attempts to move
            if (KeyboardInputManager.CheckMoveAction(moveList[i]))
            {
                bool beingDraggedWithCuffs = IsCuffed && PlayerScript.pushPull.IsBeingPulledClient;

                if (allowInput && !IsBuckled && !beingDraggedWithCuffs)
                {
                    actionKeys.Add((int)moveList[i]);
                }
                else
                {
                    if (PlayerScript.playerHealth.IsDead)
                    {
                        pna.CmdSpawnPlayerGhost();
                    }
                }
            }
        }

        return(new PlayerAction {
            moveActions = actionKeys.ToArray()
        });
    }
コード例 #5
0
    /// <summary>
    /// Processes currenlty held directional movement keys into a PlayerAction.
    /// Opposite moves on the X or Y axis cancel out, not moving the player in that axis.
    /// Moving while dead spawns the player's ghost.
    /// </summary>
    /// <returns> A PlayerAction containing up to two (non-opposite) movement directions.</returns>
    public PlayerAction SendAction()
    {
        // Stores the directions the player will move in.
        List <int> actionKeys = new List <int>();

        // Only move if player is out of UI
        if (!(PlayerManager.LocalPlayer == gameObject && UIManager.IsInputFocus))
        {
            bool moveL = KeyboardInputManager.CheckMoveAction(MoveAction.MoveLeft);
            bool moveR = KeyboardInputManager.CheckMoveAction(MoveAction.MoveRight);
            bool moveU = KeyboardInputManager.CheckMoveAction(MoveAction.MoveDown);
            bool moveD = KeyboardInputManager.CheckMoveAction(MoveAction.MoveUp);
            // Determine movement on each axis (cancelling opposite moves)
            int moveX = (moveR ? 1 : 0) - (moveL ? 1 : 0);
            int moveY = (moveD ? 1 : 0) - (moveU ? 1 : 0);

            if (moveX != 0 || moveY != 0)
            {
                bool beingDraggedWithCuffs = IsCuffed && PlayerScript.pushPull.IsBeingPulledClient;

                if (allowInput && !IsBuckled && !beingDraggedWithCuffs)
                {
                    switch (moveX)
                    {
                    case 1:
                        actionKeys.Add((int)MoveAction.MoveRight);
                        break;

                    case -1:
                        actionKeys.Add((int)MoveAction.MoveLeft);
                        break;

                    default:
                        break;                                 // Left, Right cancelled or not pressed
                    }
                    switch (moveY)
                    {
                    case 1:
                        actionKeys.Add((int)MoveAction.MoveUp);
                        break;

                    case -1:
                        actionKeys.Add((int)MoveAction.MoveDown);
                        break;

                    default:
                        break;                                 // Up, Down cancelled or not pressed
                    }
                }
                else                 // Player tried to move but isn't allowed
                {
                    if (PlayerScript.playerHealth.IsDead)
                    {
                        pna.CmdSpawnPlayerGhost();
                    }
                }
            }
        }

        return(new PlayerAction {
            moveActions = actionKeys.ToArray()
        });
    }