Пример #1
0
    public void Update()
    {
        Slider sliderOffsetAngle = GameObject.Find("Slider").GetComponent <Slider>();
        Slider sliderPitch       = GameObject.Find("Slider (1)").GetComponent <Slider>();

        player.SetBeaconOffsetAngle(-sliderOffsetAngle.value);
        player.SetBeaconPitch(sliderPitch.value);
        Debug.Log(player.GetAbsoluteOffsetAngleDifference() + ", " + player.GetAbsolutePitchDifference());
    }
Пример #2
0
    // Update is called once per frame
    private void Update()
    {
        if ((Input.touchCount > 0 && !lockTouch) && (Input.GetTouch(Input.touchCount - 1).position.y > Screen.height * 150f / 1000) && (Input.GetTouch(Input.touchCount - 1).position.y < Screen.height * 850f / 1000))
        {
            Touch latestTouch = Input.GetTouch(Input.touchCount - 1);
            if (latestTouch.phase == TouchPhase.Moved)
            {
                Camera camera = GameObject.Find("Main Camera").GetComponent <Camera>();
                locationMarkerTransform.position = camera.ScreenToWorldPoint(new Vector3(latestTouch.position.x, latestTouch.position.y, camera.nearClipPlane));

                localizationFactor = (Screen.width / 2 - latestTouch.position.x) * 90 / (Screen.width / 2); //Changes location like a slider
                if (localizationFactor > 90)
                {
                    localizationFactor = 90;
                }
                else if (localizationFactor < -90)
                {
                    localizationFactor = -90;
                }

                if (Mathf.Abs(localizationFactor) > 5)
                {
                    player.SetBeaconOffsetAngle(localizationFactor);
                }

                float registeredScreenHeight = Screen.height * 700f / 1000;
                float modifiedYPosition      = latestTouch.position.y - (Screen.height * 150f / 1000);

                if (modifiedYPosition < registeredScreenHeight / 2)
                {
                    pitchFactor = 0.5f + 0.5f * (modifiedYPosition / (registeredScreenHeight / 2f));
                }
                else
                {
                    pitchFactor = 1f + ((modifiedYPosition - registeredScreenHeight / 2f) / (registeredScreenHeight / 2f));
                }

                if (pitchFactor < 0.5f) //song starts playing backwards
                {
                    pitchFactor = 0.5f;
                }
                if (pitchFactor > 2f)
                {
                    pitchFactor = 2f;
                }

                if (Mathf.Abs(pitchFactor) > 0.05f)
                {
                    player.SetBeaconPitch(pitchFactor);
                }
            }
        }

        Debug.Log(locationMarkerTransform.position);

        //Update Time
        GameObject.Find("TimeRemaining").GetComponent <Text>().text = "Time Remaining: " + (int)(maxTime - (Time.time - startTime) + 1);

        //Check Time Limit
        if (Time.time - startTime > maxTime && !istimeLimitReached)
        {
            StartCoroutine(UIHelper.FlashCorrectIncorrectScreen(false));
            istimeLimitReached = true;
            StartNewTrial();
        }

        UIHelper.OnBackButtonClickListener("MainMenu");
    }