Esempio n. 1
0
    void HandleMouse()
    {
        IGarminNestedChart nestedChartInterface = sceneController.defaultScene.GetComponent(typeof(IGarminNestedChart)) as IGarminNestedChart;

        // At last measure, did user single tap/click? (if double tap/clicking we can skip checking scrollWheel)
        if (inputCount < 2)
        {
            float scroll = Input.GetAxis("Mouse ScrollWheel");
            // Do not zoom for Approach if not focused on the nested (scatter) chart.
            if (!sceneController.defaultScene.Equals(sceneController.approachScene) || nestedChartInterface.isDefaultState)
            {
                ZoomCamera(scroll, ZoomSpeedMouse);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (doubleClickTimeBasis == 0)
            {
                // Default state. No clicks recorded.
                lastPanPosition = Input.mousePosition;
            }
            else
            {
                // Last known state was singleClick - and another click is recorded. Test:
                if ((Time.time - doubleClickTimeBasis) > doubleClickThreshold)
                {
                    lastPanPosition = Input.mousePosition;
                    singleClick     = true;
                }
                else
                {
                    // double click
                    if (sceneController.defaultScene.Equals(sceneController.approachScene))
                    {
                        Debug.Log("B4 HandleMouse - Approach - isDefaultState? = " + nestedChartInterface.isDefaultState);
                        nestedChartInterface.isDefaultState = !nestedChartInterface.isDefaultState;
                        if (nestedChartInterface.isDefaultState)
                        {
                            ResetFOV();
                        }
                    }
                    sceneController.ToggleCameraAngle();
                    singleClick = false;
                }
            }
            doubleClickTimeBasis = Time.time;
        }
        else if (Input.GetMouseButton(0))
        {
            if (sceneController.defaultScene.Equals(sceneController.driveScene) || nestedChartInterface != null && !nestedChartInterface.isDefaultState)
            {
                Debug.Log("HandleMouse = Panning!!!");
                PanCamera(Input.mousePosition);
            }
        }
    }
Esempio n. 2
0
    public void ChangeScene(string sceneName)
    {
        Debug.Log("ChangeScene() called in Unity! sceneName = " + sceneName);
        // Reset isFocused flag on old scene.
        if (defaultScene != null)
        {
            IGarmin3DChart chartInterface = defaultScene.GetComponent(typeof(IGarmin3DChart)) as IGarmin3DChart;
            if (chartInterface != null)
            {
                chartInterface.isFocused = false;
            }
        }

        sceneNameEnum        = (SceneName)System.Enum.Parse(typeof(SceneName), sceneName);
        isIntroTransitioning = false;
        isTransitioning      = true;
        isPuttingSceneReady  = false;
        switch (sceneNameEnum)
        {
        case SceneName.APPROACH:
            defaultScene = approachScene;
            IGarminNestedChart nestedChartInterface = defaultScene.GetComponent(typeof(IGarminNestedChart)) as IGarminNestedChart;
            nestedChartInterface.isDefaultState = true;
            isCameraToggledDown = false;
            break;

        case SceneName.CHIPPING:
            isCameraToggledDown = true;
            defaultScene        = chippingScene;
            break;

        case SceneName.PUTTING:
            isCameraToggledDown = true;
            defaultScene        = puttingScene;
            break;

        // fallthrough is intentional
        case SceneName.DRIVE:
        default:
            isCameraToggledDown = false;
            defaultScene        = driveScene;
            break;
        }
        // Enable Scene
        if (defaultScene != null)
        {
            IGarmin3DChart chartInterface = defaultScene.GetComponent(typeof(IGarmin3DChart)) as IGarmin3DChart;
            chartInterface.isFocused = true;
            touchController.ResetFOV();
            Debug.Log("ChangeScene : found scene reseting Camera Fov  - " + sceneNameEnum);
        }
        else
        {
            Debug.Log("ChangeScene : could not find scene " + sceneNameEnum);
        }
    }
Esempio n. 3
0
    void HandleTouch()
    {
        if (sceneController.defaultScene.Equals(sceneController.approachScene))
        {
            nestedChartInterface = sceneController.defaultScene.GetComponent(typeof(IGarminNestedChart)) as IGarminNestedChart;
        }

        switch (Input.touchCount)
        {
        case 1:
            // If the touch began, capture its position and its finger ID. Otherwise, if the finger ID of the touch doesn't match, skip it.
            Touch touch = Input.GetTouch(0);

            if (touch.phase == TouchPhase.Moved)
            {
                if (sceneController.defaultScene.Equals(sceneController.driveScene) || nestedChartInterface != null && !nestedChartInterface.isDefaultState)
                {
                    PanCamera(touch.position);
                }
            }
            else if (touch.phase == TouchPhase.Began)
            {
                if (doubleClickTimeBasis == 0)
                {
                    // Default state. No touches recorded.
                    lastPanPosition = Input.mousePosition;
                }
                else
                {
                    // Last known state was singleClick - and another click came is recorded. Test:
                    if ((Time.time - doubleClickTimeBasis) > doubleClickThreshold)
                    {
                        singleClick     = true;
                        lastPanPosition = Input.mousePosition;
                    }
                    else
                    {
                        // double click
                        if (sceneController.defaultScene.Equals(sceneController.approachScene))
                        {
                            Debug.Log("B4 HandleTouch - Approach - isDefaultState? = " + nestedChartInterface.isDefaultState);
                            nestedChartInterface.isDefaultState = !nestedChartInterface.isDefaultState;
                            if (nestedChartInterface.isDefaultState && cam.fieldOfView != cameraDefaultFOV)
                            {
                                ResetFOV();
                            }
                        }
                        sceneController.ToggleCameraAngle();
                        singleClick = false;
                    }
                }
                doubleClickTimeBasis = Time.time;
            }
            break;

        case 2:         // Zooming
            Vector2[] newPositions = new Vector2[] { Input.GetTouch(0).position, Input.GetTouch(1).position };
            if (!wasZoomingLastFrame)
            {
                lastZoomPositions   = newPositions;
                wasZoomingLastFrame = true;
            }
            else
            {
                // Zoom based on the distance between the new positions compared to the distance between the previous positions.
                float newDistance = Vector2.Distance(newPositions [0], newPositions [1]);
                float oldDistance = Vector2.Distance(lastZoomPositions [0], lastZoomPositions [1]);
                float offset      = newDistance - oldDistance;
                if (!sceneController.defaultScene.Equals(sceneController.approachScene) || !nestedChartInterface.isDefaultState)
                {
                    ZoomCamera(offset, ZoomSpeedTouch);
                    lastZoomPositions = newPositions;
                }
            }
            break;

        default:
            wasZoomingLastFrame = false;
            break;
        }
    }