Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        //if audio alaysis is being done
        if (tool.isPlaying)
        {
            //grab the interval between beats
            interval = tool.BeatTime();

            //add realtime to whenToChange
            whenToChange += Time.deltaTime;

            //if it's time to change the color
            if (whenToChange > interval && interval != 0)
            {
                //change colors
                if (index == colors.Length - 1)
                {
                    camera.backgroundColor = Color.Lerp(colors[index - 1], colors[0], changeSpeed);
                    index = 0;
                }

                //reset values
                camera.backgroundColor = Color.Lerp(colors[index], colors[index + 1], changeSpeed);
                whenToChange           = 0;
                index++;
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (tool.isPlaying)
        {
            interval     = tool.BeatTime();
            whenToSpawn += Time.deltaTime;

            if (whenToSpawn > interval && interval != 0)
            {
                if (hasSpawned)
                {
                    hasSpawned  = false;
                    whenToSpawn = 0;
                }
                else
                {
                    Vector3 newPos  = new Vector3(transform.position.x, transform.position.y, 0f);
                    int     tempNum = rand.Next(0, 3);
                    if (num == 2 && tempNum == 2)
                    {
                        tempNum = 0;
                        num     = 0;
                    }

                    if (tempNum == 1 && health.playerHealth == 3)
                    {
                        tempNum = 0;
                    }
                    Instantiate(enemies[tempNum], newPos, Quaternion.identity);
                    num         = tempNum;
                    hasSpawned  = true;
                    whenToSpawn = 0;
                }
            }
        }
    }