Пример #1
0
    private void MouseUpdate()
    {
        Vector2 mousePosition = Input.mousePosition;

        if (Input.GetMouseButtonDown(0))
        {
            if (!OverlapTest(mousePosition))
            {
                unitSelector.KeyPressed(cameraControl.TransformCameraToWorld(mousePosition));
                targetPosition = mousePosition;
            }
        }
        else if (Input.GetMouseButton(0))
        {
            if ((mousePosition - targetPosition).sqrMagnitude > 0.01f)
            {
                unitSelector.KeyMoved(cameraControl.TransformCameraToWorld(mousePosition));
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            unitSelector.KeyReleased(cameraControl.TransformCameraToWorld(mousePosition));
        }
        cameraControl.Zoom(Input.GetAxis("Zoom") * mouseZoomFactor * Time.deltaTime * camera.orthographicSize);
        cameraControl.Translate(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * mouseMovementFactor * camera.orthographicSize * Time.deltaTime);
        cameraControl.UpdateControlPoints();
        cameraControl.AdjustZoom();
        cameraControl.UpdateControlPoints();
        cameraControl.AdjustPosition();
    }