Esempio n. 1
0
        private void UpdateInput()
        {
            if (maskGraphicTrigger && DeviceInput.UF_Press(0))
            {
                if (uiCamera == null)
                {
                    return;
                }
                //停止复位
                m_IsResumePoint = false;

                if (!m_IsPress)
                {
                    m_SourceDragPos = DeviceInput.UF_DownPosition(0);
                    joyRoot.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_SourceDragPos);
                    m_IsPress = true;
                    UF_CallDelegateEvent(m_EventJoyPressDown);
                    UF_CallUnityEvent(m_UEventPressDown);
                }
                if (m_IsPress)
                {
                    m_TargetDragPos = DeviceInput.UF_PressPosition(0);
                    float dist   = Vector3.Distance(m_SourceDragPos, m_TargetDragPos);
                    float limitV = limtPointDistance * Screen.width / UIManager.FixedWidth;

                    if (dist > limitV)
                    {
                        m_TargetDragPos = m_SourceDragPos + (m_TargetDragPos - m_SourceDragPos).normalized * limitV;
                    }
                    if (joyPoint != null)
                    {
                        joyPoint.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_TargetDragPos);
                    }
//					float angle = 0;
                    Vector3 _moveVector = MathX.UF_Foward(m_SourceDragPos, m_TargetDragPos);
                    if (dist > deadZoom)
                    {
                        m_MoveForward = new Vector3(_moveVector.x, gravity, _moveVector.y).normalized;
                        UF_CallDelegateEvent(m_EventJoyPressMove);
                        UF_UpdateRotate(m_MoveForward);
                    }
                }
            }
            else
            {
                if (m_IsPress)
                {
                    m_IsPress = false;
                    UF_ResumePoint(); UF_UpdateRevertRoot();
                    UF_CallDelegateEvent(m_EventJoyPressUp);
                    UF_CallUnityEvent(m_UEventPressUp);
                }
            }
        }
Esempio n. 2
0
        // Update is called once per frame
        public void UF_OnUpdate()
        {
            if (!IsActive)
            {
                return;
            }
            if (m_IsPress && UsePress)
            {
                m_CurrentPressTime += GTime.RunDeltaTime;
                if (m_CurrentPressTime >= PressInterval)
                {
                    m_CurrentPressTime = 0;
                    RaycastHit hit;
                    Camera     camera = Camera.main;
                    if (camera != null && !IsUIRayCast() && Physics.Raycast(camera.ScreenPointToRay(DeviceInput.UF_PressPosition(0)), out hit, Distance))
                    {
                        MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_LUA, DefineLuaEvent.E_RAYCAST_HIT, hit);
                    }
                }
                if (!DeviceInput.UF_Press(0))
                {
                    m_CurrentPressTime = 0;
                }
            }
            else
            {
                if (DeviceInput.UF_Down(0))
                {
                    RaycastHit hit;
                    Camera     camera = Camera.main;
                    if (camera != null && !IsUIRayCast() && Physics.Raycast(camera.ScreenPointToRay(DeviceInput.UF_PressPosition(0)), out hit, Distance))
                    {
                        if (UsePress)
                        {
                            m_IsPress          = true;
                            m_CurrentPressTime = 0;
                        }
                        MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_LUA, DefineLuaEvent.E_RAYCAST_HIT, hit);
                    }
                }
            }

            if (!DeviceInput.UF_Press())
            {
                m_IsPress = false;
            }
        }