예제 #1
0
    public void SwitchTimeScale()
    {
        switch (timeScale)
        {
        case 0:
            beatSource.PlayScheduled(SimpleClock.AtNextMeasure());
            break;

        case 1:
            beatSource.PlayScheduled(SimpleClock.AtNextQuarter());
            break;

        case 2:
            beatSource.PlayScheduled(SimpleClock.AtNextEighth());
            break;

        case 3:
            beatSource.PlayScheduled(SimpleClock.AtNextSixteenth());
            break;

        case 4:
            beatSource.PlayScheduled(SimpleClock.AtNextThirtySecond());
            break;
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (audio.isPlaying)
        {
            timer -= Time.deltaTime;
            if (timer > 0)
            {
                sprVisisble = true;
            }
            else
            {
                sprVisisble = false;
            }
        }
        else
        {
            timer = timerStartVal;
        }
        if (GetComponent <growPlants> ().growthNumber == 1)
        {
            if (!clipsSwitched)
            {
                audio.clip    = clips [Random.Range(0, 7)];
                clipsSwitched = true;
            }
            if (!playedAudio)
            {
                //timeScale = Random.Range (0, 4);

                if (timeScale == 1)
                {
                    audio.PlayScheduled(SimpleClock.AtNextMeasure());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 2)
                {
                    audio.PlayScheduled(SimpleClock.AtNextMeasure());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 3)
                {
                    audio.PlayScheduled(SimpleClock.AtNextMeasure());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                    playedAudio = true;
                }
                else if (timeScale == 0)
                {
                    audio.PlayScheduled(SimpleClock.AtNextMeasure());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                    playedAudio = true;
                }
            }
            else
            {
                if (!audio.isPlaying && audio.outputAudioMixerGroup == regularMix)
                {
                    audio.outputAudioMixerGroup = silentMix;
                    //lastClip = audio.clip;

                    //audio.clip = null;

                    if (timeScale == 1)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextMeasure());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                        //playedAudio = true;
                    }
                    else if (timeScale == 2)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                        audio.SetScheduledEndTime(SimpleClock.AtNextEighthTriplet() + SimpleClock.AtNextHalf());
                        //playedAudio = true;
                    }
                    else if (timeScale == 3)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                        //playedAudio = true;
                    }
                    else if (timeScale == 0)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                        //playedAudio = true;
                    }

                    //playedAudio = false;
                }
                else if (!audio.isPlaying && audio.outputAudioMixerGroup == silentMix)
                {
                    audio.outputAudioMixerGroup = regularMix;
                    playedAudio = false;
                }
                else
                {
                }
            }
        }
        else if (GetComponent <growPlants> ().growthNumber == 2)
        {
            if (!clipsSwitched)
            {
                audio.clip    = switchedClips [Random.Range(0, 3)];
                clipsSwitched = true;
            }
            if (!playedAudio)
            {
                //timeScale = Random.Range (0, 4);

                if (timeScale == 1)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 2)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 3)
                {
                    audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                    playedAudio = true;
                }
                else if (timeScale == 0)
                {
                    audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                    playedAudio = true;
                }
            }
            else
            {
                if (!audio.isPlaying && audio.outputAudioMixerGroup == regularMix)
                {
                    audio.outputAudioMixerGroup = silentMix;
                    //lastClip = audio.clip;

                    //audio.clip = null;

                    if (timeScale == 1)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextEighth());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                        //playedAudio = true;
                    }
                    else if (timeScale == 2)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                        //playedAudio = true;
                    }
                    else if (timeScale == 3)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                        //playedAudio = true;
                    }
                    else if (timeScale == 0)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                        //playedAudio = true;
                    }

                    //playedAudio = false;
                }
                else if (!audio.isPlaying && audio.outputAudioMixerGroup == silentMix)
                {
                    audio.outputAudioMixerGroup = regularMix;
                    playedAudio = false;
                }
                else
                {
                }
            }
        }
        else if (GetComponent <growPlants> ().growthNumber == 3)
        {
            if (!clipsSwitched)
            {
                audio.clip    = secondClips [Random.Range(0, 4)];
                clipsSwitched = true;
            }
            if (!playedAudio)
            {
                //timeScale = Random.Range (0, 4);

                if (timeScale == 1)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 2)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                    playedAudio = true;
                }
                else if (timeScale == 3)
                {
                    audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                    playedAudio = true;
                }
                else if (timeScale == 0)
                {
                    audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                    playedAudio = true;
                }
            }
            else
            {
                if (!audio.isPlaying && audio.outputAudioMixerGroup == regularMix)
                {
                    audio.outputAudioMixerGroup = silentMix;
                    //lastClip = audio.clip;

                    //audio.clip = null;

                    if (timeScale == 1)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextEighth());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                        //playedAudio = true;
                    }
                    else if (timeScale == 2)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                        //playedAudio = true;
                    }
                    else if (timeScale == 3)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                        //playedAudio = true;
                    }
                    else if (timeScale == 0)
                    {
                        audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                        //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                        //playedAudio = true;
                    }

                    //playedAudio = false;
                }
                else if (!audio.isPlaying && audio.outputAudioMixerGroup == silentMix)
                {
                    audio.outputAudioMixerGroup = regularMix;
                    playedAudio = false;
                }
                else
                {
                }
            }
        }
        else
        {
            audio.Stop();
        }
        //audio.PlayScheduled (SimpleClock.AtNextEighth());

        /*	if (GetComponent<growPlants> ().growthNumber == 1) {
         *      if (!playedAudio) {
         *              audio.clip = clips [Random.Range (0, 1)];
         *              playedAudio = true;
         *      }
         *      //print ("playing");
         *      }
         *      if (GetComponent<growPlants> ().growthNumber == 2) {
         *      if (!playedAudio) {
         *              audio.clip = clips [Random.Range (1, 2)];
         *              playedAudio = true;
         *      }
         *      }
         *      if (GetComponent<growPlants> ().growthNumber == 3) {
         *      if (!playedAudio) {
         *              audio.clip = clips [Random.Range (2, 3)];
         *              playedAudio = true;
         *      }
         *      } else {
         *      if (!playedAudio) {
         *              audio.clip = null;
         *              playedAudio = true;
         *      }
         *      }
         *
         * //}
         *
         * if (!audio.isPlaying) {
         *      audio.Play ();
         * }
         */
    }
예제 #3
0
    void AudioCycler()
    {
        if (!playedAudio)
        {
            timeScale = Random.Range(0, 4);

            if (timeScale == 1)
            {
                audio.PlayScheduled(SimpleClock.AtNextEighth());
                //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                playedAudio = true;
            }
            else if (timeScale == 2)
            {
                audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                playedAudio = true;
            }
            else if (timeScale == 3)
            {
                audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                playedAudio = true;
            }
            else if (timeScale == 0)
            {
                audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                playedAudio = true;
            }
        }
        else
        {
            if (!audio.isPlaying && audio.outputAudioMixerGroup == regularMix)
            {
                audio.outputAudioMixerGroup = silentMix;
                //lastClip = audio.clip;

                //audio.clip = null;

                if (timeScale == 1)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextSixteenthTriplet () + SimpleClock.AtNextHalf ());
                    //playedAudio = true;
                }
                else if (timeScale == 2)
                {
                    audio.PlayScheduled(SimpleClock.AtNextEighthTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextEighth() + SimpleClock.AtNextHalf ());
                    //playedAudio = true;
                }
                else if (timeScale == 3)
                {
                    audio.PlayScheduled(SimpleClock.AtNextSixteenth());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextHalf () + SimpleClock.AtNextSixteenth());
                    //playedAudio = true;
                }
                else if (timeScale == 0)
                {
                    audio.PlayScheduled(SimpleClock.AtNextQuarterTriplet());
                    //audio.SetScheduledEndTime (SimpleClock.AtNextQuarter() + SimpleClock.AtNextBeat());
                    //playedAudio = true;
                }

                //playedAudio = false;
            }
            else if (!audio.isPlaying && audio.outputAudioMixerGroup == silentMix)
            {
                audio.outputAudioMixerGroup = regularMix;
                playedAudio = false;
            }
        }
    }