IEnumerator FadeInSurfaceTrack() { if (fadedIn || playingTrack == AmbienceTrack.Surface) { yield break; } AudioSource trackPlayer = ambienceSourceMain; AudioSource altTrackPlayer = ambienceSourceSecondary; if (ambienceSourceMain.isPlaying) { altTrackPlayer = ambienceSourceMain; trackPlayer = ambienceSourceSecondary; } trackPlayer.clip = ambienceTracks[0]; trackPlayer.Play(); while (trackPlayer.volume < 1) { trackPlayer.volume += fadeInIncrement; altTrackPlayer.volume -= fadeInIncrement; yield return(new WaitForSeconds(fadeInDelay)); } trackPlayer.volume = 1; altTrackPlayer.volume = 0; fadedIn = true; altTrackPlayer.Stop(); playingTrack = AmbienceTrack.Surface; fadingTrack = AmbienceTrack.None; }
public void FadeInAmbience(AmbienceTrack _track) { if (fadingTrack != _track) { switch (_track) { case AmbienceTrack.Surface: fadedIn = false; fadingTrack = _track; StartCoroutine(FadeInSurfaceTrack()); break; case AmbienceTrack.UpperLayers: fadedIn = false; fadingTrack = _track; StartCoroutine(FadeInUndergroundTrack()); break; case AmbienceTrack.DarkCaves: fadedIn = false; fadingTrack = _track; StartCoroutine(FadeInDeepCavesTrack()); break; } } }
public ActiveAmbienceTrack(AmbienceTrack track, bool activeForDayPhase) { ServiceHelper.InjectServices((object)this); this.volume = 0.0f; this.ActiveForDayPhase = activeForDayPhase; this.OnMuteStateChanged(); this.Track = track; this.cue = this.SoundManager.GetCue(this.Track.Name, false); this.cue.Volume = this.volume; this.cue.Play(); }