// Start is called before the first frame update
    void Start()
    {
        if (background != null)
        {
            Image bground = GameObject.Find("Background").GetComponent <Image>();
            bground.sprite = background;
        }

        MagnifyGlass.DisableZoom();

        continueButton  = GameObject.Find("Continue").GetComponent <Button>();
        continueAction += continueFunction;
        continueButton.onClick.AddListener(continueAction);

        bugsClickedText = GameObject.Find("BugsClicked").GetComponent <Text>();

        bugsIdentifiedText = GameObject.Find("BugsIdentified").GetComponent <Text>();

        measurementAccuracyText = GameObject.Find("MeasurementAccuracy").GetComponent <Text>();
        if (GameManager.instance.bugsClicked > 0)
        {
            bugsClickedText.text         = "Arthropods found: " + Mathf.Round(100 * (float)GameManager.instance.bugsClicked / GameManager.instance.totalBugs) + "%";
            bugsIdentifiedText.text      = "Correctly identified: " + Mathf.Round(100 * (float)GameManager.instance.bugsCorrectlyIdentified / GameManager.instance.totalBugs) + "%";
            measurementAccuracyText.text = "Measurement error: " + Mathf.Round((float)(GameManager.instance.measurementDistance / GameManager.instance.bugsClicked)) + "mm";
        }
        else
        {
            bugsClickedText.text         = "";
            bugsIdentifiedText.text      = "";
            measurementAccuracyText.text = "No bugs were clicked on!";
        }

        playerScoreText      = GameObject.Find("UserScore").GetComponent <Text>();
        playerScoreText.text = "Your Score: " + ScoreScript.levelScore + "/" + GameManager.instance.levelScore;
    }
Esempio n. 2
0
    void Start()
    {
        MagnifyGlass.DisableZoom();

        playButton  = gameObject.GetComponentInChildren <Button>();
        playAction += Play;
        playButton.onClick.AddListener(playAction);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return) && measurementInput != null)
        {
            EvaluateMeasurement(measurementInput);
            measurementInput.DeactivateInputField();
        }

        if (Input.GetMouseButtonDown(0))
        {
            MagnifyGlass.DisableZoom();
        }

        if (Input.GetMouseButtonDown(1) && !MagnifyGlass.IsZoomable())
        {
            MagnifyGlass.ResetCounter();
            MagnifyGlass.EnableZoom();
        }

        if (TimerScript.GetCurrentTime() <= 0)
        {
            Submit();
        }

        //Might want to make these into coroutines to delay the zoom a bit
        //Linearly interpolates between the default camera view and the zoomed view. Updates each frame for a smoother zoom effect
        if (zoomingIn)
        {
            if (Camera.main.orthographicSize <= zoomedFOV)
            {
                zoomingIn = false;
                Camera.main.orthographicSize = zoomedFOV;
            }
            else
            {
                Camera.main.orthographicSize += Time.deltaTime * -zoomInSpeed;
            }
        }

        if (zoomingOut)
        {
            if (Camera.main.orthographicSize >= defaultFOV)
            {
                zoomingOut = false;
                Camera.main.orthographicSize = defaultFOV;
            }
            else
            {
                Camera.main.orthographicSize += Time.deltaTime * zoomOutSpeed;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            MagnifyGlass.DisableZoom();
        }

        if (Input.GetMouseButtonDown(1) && !MagnifyGlass.IsZoomable())
        {
            MagnifyGlass.ResetCounter();
            MagnifyGlass.EnableZoom();
        }

        if (TimerScript.GetCurrentTime() <= 0)
        {
            Submit();
        }

        //Might want to make these into coroutines to delay the zoom a bit
        //Linearly interpolates between the default camera view and the zoomed view. Updates each frame for a smoother zoom effect
        if (zoomingIn)
        {
            Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, zoomedFOV, Time.deltaTime * zoomInSpeed);
            if (Camera.main.orthographicSize <= zoomedFOV)
            {
                zoomingIn = false;
            }
        }

        if (zoomingOut)
        {
            Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, defaultFOV, Time.deltaTime * zoomOutSpeed);
            if (Camera.main.orthographicSize >= defaultFOV)
            {
                zoomingOut = false;
                Camera.main.orthographicSize = defaultFOV;
            }
        }
    }