示例#1
0
    void Update()
    {
        if (isMine)
        {
            if (!m_ActionRequested)
            {
                if (m_CharacterInput != null)
                {
                    m_ActionRequested = m_CharacterInput.GetButtonDown(InputActions.s_AttractButton);
                }
                else
                {
                    m_ActionRequested = false;
                }
            }

            if (m_CharacterInput != null)
            {
                m_ButtonPressed = m_CharacterInput.GetButton(InputActions.s_AttractButton);
            }
            else
            {
                m_ButtonPressed = false;
            }
        }

        if (m_Graphics != null)
        {
            m_Graphics.SetActive(m_Running);
        }
    }
    // tnISyncablePlayerInput's interface

    public void SyncedInput(tnInput o_Input)
    {
        float horizontalAxis = m_CharacterInput.GetAxis(InputActions.s_HorizontalAxis);
        float verticalAxis   = m_CharacterInput.GetAxis(InputActions.s_VerticalAxis);

        bool buttonPressed = m_CharacterInput.GetButton(InputActions.s_PassButton);

        if (m_EnableInputCompression)
        {
            int intX = (int)(horizontalAxis * s_InputPrecision);
            int intY = (int)(verticalAxis * s_InputPrecision);

            o_Input.SetInt(m_HorizontalAxisCode, intX);
            o_Input.SetInt(m_VerticalAxisCode, intY);
        }
        else
        {
            o_Input.SetFP(m_HorizontalAxisCode, FP.FromFloat(horizontalAxis));
            o_Input.SetFP(m_VerticalAxisCode, FP.FromFloat(verticalAxis));
        }

        o_Input.SetByte(m_ButtonPressedCode, buttonPressed ? (byte)1 : (byte)0);
    }