/// <summary> /// Updates the background music controller. /// </summary> /// <param name="elapsedTimeS">The elapsed time in seconds since the last update.</param> public void Update(float elapsedTimeS) { if (this.currentSong.FinishedPlaying) { this.propagateSong(); } if (this.currentFade != null) { this.currentFade.Update(elapsedTimeS); this.localVolume = this.currentFade.CurrentVolume; this.OnVolumeChanged(this.globalVolume); if (this.currentFade.Finished) { this.currentFade = null; if (this.fadeCallback != null) { this.fadeCallback(); this.fadeCallback = null; } } } }
/// <summary> /// Fades out this background music controller. /// </summary> /// <param name="length">The length of this fade.</param> /// <param name="callback">The method that should be called when the fade is finished.</param> public void FadeOut(float length, Action callback) { this.currentFade = new FadeDefinition(length, this.localVolume, 0); this.fadeCallback = callback; }