예제 #1
0
        private void Update()
        {
            if (m_gameState.IsActionsMenuOpened(m_viewport.LocalPlayerIndex))
            {
                return;
            }

            if (m_gameState.IsMenuOpened(m_viewport.LocalPlayerIndex))
            {
                return;
            }

            if (m_gameState.IsPaused || m_gameState.IsPauseStateChanging)
            {
                return;
            }

            Transform camTransform = m_viewport.Camera.transform;

            if (camTransform.position != m_prevCamPos || camTransform.rotation != m_prevCamRot)
            {
                m_prevCamPos = camTransform.position;
                m_prevCamRot = camTransform.rotation;

                float angle = camTransform.eulerAngles.y;
                m_rtMapBounds.rotation = Quaternion.Euler(new Vector3(0, 0, angle));

                ProjectCamera(m_rtMapBounds.rotation);
            }

            if (m_input.GetButtonDown(InputAction.Start, m_viewport.LocalPlayerIndex, false, false))
            {
                m_gotFocus = !m_gotFocus;
                if (m_gotFocus)
                {
                    m_eventSystem.SetSelectedGameObjectOnLateUpdate(m_selectableMinimap.gameObject);
                }
                else
                {
                    m_cameraController.CenterVirtualMouse();
                    m_eventSystem.SetSelectedGameObjectOnLateUpdate(null);
                }
            }

            if (m_input.GetButtonDown(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false))
            {
                Vector2 pt;
                if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)m_rtMapBounds.parent, m_cameraController.VirtualMousePosition, null, out pt))
                {
                    float normalizedDistance = pt.magnitude / m_rootRadius;
                    if (normalizedDistance <= 1)
                    {
                        m_mouseManipulation   = true;
                        m_virtualMousePostion = m_cameraController.VirtualMousePosition;
                        Move(camTransform, true, 0, 0, 0, 0);
                    }
                }
            }
            else if (m_input.GetButtonUp(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false))
            {
                m_mouseManipulation = false;
            }

            if (m_gotFocus || m_input.GetButton(InputAction.LB, m_viewport.LocalPlayerIndex, false, false) && IsCursorInMinimapBounds())
            {
                if (m_input.GetButtonDown(InputAction.B, m_viewport.LocalPlayerIndex, false, false))
                {
                    m_gotFocus = false;
                    m_cameraController.CenterVirtualMouse();
                    m_eventSystem.SetSelectedGameObjectOnLateUpdate(null);
                }
                else if (m_input.GetButtonDown(InputAction.LB, m_viewport.LocalPlayerIndex, false, false))
                {
                    m_virtualMousePostion = m_cameraController.VirtualMousePosition;
                    Move(camTransform, true, 0, 0, 0, 0);
                }
                else
                {
                    bool aPressed         = m_input.GetButton(InputAction.A, m_viewport.LocalPlayerIndex, false, false);
                    bool pivotPreciseMode = aPressed | m_input.GetButton(InputAction.RightStickButton, m_viewport.LocalPlayerIndex, false, false);

                    float pivotMultiplier = 1;
                    if (!pivotPreciseMode)
                    {
                        pivotMultiplier = 5;
                    }

                    float deltaY = m_input.GetAxisRaw(InputAction.MoveForward, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier;
                    float deltaX = m_input.GetAxisRaw(InputAction.MoveSide, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.MoveSensitivity * pivotMultiplier;

                    bool  cursorPreciseMode = aPressed | m_input.GetButton(InputAction.LeftStickButton, m_viewport.LocalPlayerIndex, false, false);
                    float cursorMultiplier  = 4;
                    if (!cursorPreciseMode)
                    {
                        cursorMultiplier = 12;
                    }
                    float cursorY = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier;
                    float cursorX = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier;

                    Move(camTransform, false, deltaY, deltaX, cursorY, cursorX);
                }
            }

            if (m_mouseManipulation)
            {
                if (m_input.GetButton(InputAction.LMB, m_viewport.LocalPlayerIndex, false, false))
                {
                    float cursorMultiplier = 12;
                    float cursorY          = m_input.GetAxisRaw(InputAction.CursorY, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier;
                    float cursorX          = m_input.GetAxisRaw(InputAction.CursorX, m_viewport.LocalPlayerIndex, false, false) * Time.deltaTime * m_camCtrlSettings.CursorSensitivity * cursorMultiplier;

                    Move(camTransform, false, cursorY, cursorX, 0, 0);
                }
            }
        }