private void UpdateTouchAction()
        {
            NREmulatorManager.Instance.NativeEmulatorApi.SetControllerIsTouching(true);
            const int kActionMaxFrame = 20;
            float     touchx          = 0;
            float     touchy          = 0;

            if (m_TouchAction == TouchActionState.Left)
            {
                touchy = kHeight / 2;
                touchx = 0.1f * kWidth + ((float)(kActionMaxFrame - m_TouchActionCurFrame) / kActionMaxFrame) * (0.8f * kWidth);
            }
            else if (m_TouchAction == TouchActionState.Right)
            {
                touchy = kHeight / 2;
                touchx = 0.1f * kWidth + ((float)m_TouchActionCurFrame / kActionMaxFrame) * (0.8f * kWidth);
            }
            else if (m_TouchAction == TouchActionState.Up)
            {
                touchx = kWidth / 2;
                touchy = 0.1f * kHeight + ((float)(kActionMaxFrame - m_TouchActionCurFrame) / kActionMaxFrame) * (0.8f * kHeight);
            }
            else if (m_TouchAction == TouchActionState.Down)
            {
                touchx = kWidth / 2;
                touchy = 0.1f * kHeight + ((float)m_TouchActionCurFrame / kActionMaxFrame) * (0.8f * kHeight);
            }

            NREmulatorManager.Instance.NativeEmulatorApi.SetControllerTouchPoint(touchx - 1f, touchy - 1f);

            if (m_TouchActionCurFrame == kActionMaxFrame)
            {
                m_TouchActionCurFrame = 0;
                m_TouchAction         = TouchActionState.Idle;
                ImageLeft.SetActive(false);
                ImageRight.SetActive(false);
                ImageUp.SetActive(false);
                ImageDown.SetActive(false);
            }

            m_TouchActionCurFrame++;
        }
 private void UpdateDefaultControllerButtons()
 {
     if (Input.GetMouseButtonDown(0))
     {
         SetConfirmButton(true);
         ImageConfirm.SetActive(true);
     }
     if (Input.GetMouseButtonUp(0))
     {
         SetConfirmButton(false);
         ImageConfirm.SetActive(false);
     }
     if (Input.GetMouseButtonDown(1))
     {
         SetAppButton(true);
         ImageApp.SetActive(true);
     }
     if (Input.GetMouseButtonUp(1))
     {
         SetAppButton(false);
         ImageApp.SetActive(false);
     }
     if (Input.GetMouseButtonDown(2))
     {
         SetHomeButton(true);
         ImageHome.SetActive(true);
     }
     if (Input.GetMouseButtonUp(2))
     {
         SetHomeButton(false);
         ImageHome.SetActive(false);
     }
     if (m_TouchAction != TouchActionState.Idle)
     {
         UpdateTouchAction();
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.LeftArrow))
         {
             ImageLeft.SetActive(true);
             m_TouchAction = TouchActionState.Left;
         }
         else if (Input.GetKeyDown(KeyCode.RightArrow))
         {
             ImageRight.SetActive(true);
             m_TouchAction = TouchActionState.Right;
         }
         else if (Input.GetKeyDown(KeyCode.UpArrow))
         {
             ImageUp.SetActive(true);
             m_TouchAction = TouchActionState.Up;
         }
         else if (Input.GetKeyDown(KeyCode.DownArrow))
         {
             ImageDown.SetActive(true);
             m_TouchAction = TouchActionState.Down;
         }
         else if (Input.GetKeyUp(KeyCode.DownArrow)
                  | Input.GetKeyUp(KeyCode.UpArrow)
                  | Input.GetKeyUp(KeyCode.RightArrow)
                  | Input.GetKeyUp(KeyCode.LeftArrow))
         {
             NREmulatorManager.Instance.NativeEmulatorApi.SetControllerIsTouching(false);
         }
     }
 }
Exemple #3
0
        void LateUpdate()
        {
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
            {
                UpdateControllerRotateByInput();
            }

            if (Input.GetMouseButtonDown(0))
            {
                SetConfirmButton(true);
                ImageConfirm.SetActive(true);
            }
            if (Input.GetMouseButtonUp(0))
            {
                SetConfirmButton(false);
                ImageConfirm.SetActive(false);
            }
            if (Input.GetMouseButtonDown(2))
            {
                SetAppButton(true);
                ImageApp.SetActive(true);
            }
            if (Input.GetMouseButtonUp(2))
            {
                SetAppButton(false);
                ImageApp.SetActive(false);
            }
            if (Input.GetMouseButtonDown(1))
            {
                SetHomeButton(true);
                ImageHome.SetActive(true);
            }
            if (Input.GetMouseButtonUp(1))
            {
                SetHomeButton(false);
                ImageHome.SetActive(false);
            }
            if (m_TouchAction != TouchActionState.Idle)
            {
                UpdateTouchAction();
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    ImageLeft.SetActive(true);
                    m_TouchAction = TouchActionState.Left;
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    ImageRight.SetActive(true);
                    m_TouchAction = TouchActionState.Right;
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    ImageUp.SetActive(true);
                    m_TouchAction = TouchActionState.Up;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    ImageDown.SetActive(true);
                    m_TouchAction = TouchActionState.Down;
                }
                else if (Input.GetKeyUp(KeyCode.DownArrow)
                         | Input.GetKeyUp(KeyCode.UpArrow)
                         | Input.GetKeyUp(KeyCode.RightArrow)
                         | Input.GetKeyUp(KeyCode.LeftArrow))
                {
                    NREmulatorManager.Instance.NativeEmulatorApi.SetControllerIsTouching(false);
                }
            }

            NREmulatorManager.Instance.NativeEmulatorApi.SetControllerSubmit();


            if (NRInput.GetButtonDown(ControllerButton.TRIGGER))
            {
                NRDebugger.Log("Click down Trigger button !!!");
            }
            else if (NRInput.GetButtonDown(ControllerButton.APP))
            {
                NRDebugger.Log("Click down App button !!!");
            }
            else if (NRInput.GetButtonDown(ControllerButton.HOME))
            {
                NRDebugger.Log("Click down Home button !!!");
            }
        }