// Update is called once per frame
    void Update()
    {
        //musicPlayer.pitch = minPitch + ((maxPitch - minPitch) * lcon.CalculateMusicSpeed());

        if (isTransitioningToDifferentPitch)
        {
            if (timer < lerpTime)
            {
                float from = minPitch + (maxPitch - minPitch) * ((float)curNumLights) / totalNumLights;
                float to   = minPitch + (maxPitch - minPitch) * ((float)lcon.GetLightCount()) / totalNumLights;
                musicPlayer.pitch = Mathf.Lerp(from, to, timer);
                timer            += Time.deltaTime;
            }
            else
            {
                timer = 0f;
                isTransitioningToDifferentPitch = false;
                curNumLights = lcon.GetLightCount();
            }
        }
        else
        {
            musicPlayer.pitch = minPitch + (maxPitch - minPitch) * ((float)curNumLights) / totalNumLights;
        }

        if (curNumLights != lcon.GetLightCount())
        {
            isTransitioningToDifferentPitch = true;
        }
    }
Beispiel #2
0
    private void Update()
    {
        if (Player == null)
        {
            Player = GameObject.Find("Player");
        }
        if (finishPortal == null)
        {
            finishPortal = GameObject.Find("Finish Portal");
        }
        if (lights == null)
        {
            lights = GameObject.Find("Lights");
        }
        if (lcon == null)
        {
            if (Player != null)
            {
                lcon = Player.transform.Find("LightContainer").GetComponent <LightContainerController>();
            }
        }
        if (!curLevelIsFinished)
        {
            timer += Time.deltaTime;
        }

        if (Player != null)
        {
            int numLightsCollected = lcon.GetLightCount();
            if (finishPortal != null)
            {
                if (AllLightsCollected(numLightsCollected))
                {
                    finishPortal.SetActive(true);
                    finishPortal.transform.GetChild(0).gameObject.SetActive(true);
                }
                else
                {
                    finishPortal.SetActive(false);
                }
            }
        }



        TimeText.text = (Mathf.Round(timer * 100f) / 100f).ToString() + " s";

        //Debug.Log("Light Movement Factor ------------> " + lcon.GetLightMovementFactor());
    }