Exemple #1
0
    public IEnumerator PowerCrossFade()
    {
        float i = 0f;

        CurrentAudio audioToSwitch;

        audioToSwitch = currentAudioPlaying == CurrentAudio.OVERWORLD ? CurrentAudio.BATTLE : CurrentAudio.OVERWORLD;

        audioS[(int)audioToSwitch].timeSamples = audioS[(int)currentAudioPlaying].timeSamples;
        audioS[(int)audioToSwitch].Play();

        while (paused)
        {
            yield return(null);
        }

        while (i < 1f)
        {
            i += 1.25f * Time.deltaTime;
            audioS[(int)currentAudioPlaying].volume = Mathf.Lerp(1f, 0f, i);
            audioS[(int)audioToSwitch].volume       = Mathf.Lerp(0f, 1f, i);
            yield return(new WaitForSeconds(0));
        }

        audioS[(int)currentAudioPlaying].Stop();
        currentAudioPlaying = audioToSwitch;

        GameManager.INSTANCE.fadeEnded = true;
    }
Exemple #2
0
 private void Awake()
 {
     bpm    = songMap.BPM;
     audioS = GetComponents <AudioSource>();
     currentAudioPlaying = CurrentAudio.OVERWORLD;
 }