Exemple #1
0
    /*
     *  ProcessUserCmd
     *  Parameters:
     *  1) UserCmd cmd
     *      This is the usercmd that we're going to process, this code should only be called on the server instance of the object
     *  TODO(Jake): Allow the local player to process their own usercmd upon creation AKA Client-Sided Prediction
     *  https://en.wikipedia.org/wiki/Client-side_prediction
     */
    public void ProcessUserCmd(UserCmd cmd)
    {
        if (cmd.ActionPressed(PlayerInputSynchronization.IN_FIRE))
        {
            //Fire!
        }
        if (cmd.ActionPressed(PlayerInputSynchronization.IN_ACCELERATE))
        {
            //Accelerate!
            Debug.Log("Accelerate!");
        }

        bool moveLeft  = cmd.ActionPressed(PlayerInputSynchronization.IN_LEFT),
             moveRight = cmd.ActionPressed(PlayerInputSynchronization.IN_RIGHT);

        if (moveLeft ^ moveRight)
        {
            if (moveLeft)
            {
                m_TargetController.HorizontalMoveDirection = -1;
            }
            else
            {
                m_TargetController.HorizontalMoveDirection = 1;
            }
        }
        else
        {
            m_TargetController.HorizontalMoveDirection = 0;
        }

        if (cmd.ActionPressed(PlayerInputSynchronization.IN_RIGHT))
        {
        }
    }