diff options
| author | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
| commit | a22c505984697881f5f911a165ee022087b69e09 (patch) | |
| tree | d3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_1_0/Decompile/AudioDayNightFader.cs | |
| parent | 4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff) | |
Diffstat (limited to 'Thronefall_1_0/Decompile/AudioDayNightFader.cs')
| -rw-r--r-- | Thronefall_1_0/Decompile/AudioDayNightFader.cs | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/Thronefall_1_0/Decompile/AudioDayNightFader.cs b/Thronefall_1_0/Decompile/AudioDayNightFader.cs deleted file mode 100644 index 7734d83..0000000 --- a/Thronefall_1_0/Decompile/AudioDayNightFader.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections; -using UnityEngine; -using UnityEngine.Audio; - -public class AudioDayNightFader : MonoBehaviour, DayNightCycle.IDaytimeSensitive -{ - public float fadeTime = 0.5f; - - public AudioMixer mixer; - - public AudioClip nightMusic; - - public AudioClip finalNightMusic; - - public float nightMusicFadeInTime = 3f; - - public float nightMusicFadeOutTime = 4f; - - private float transitionClock; - - private float dayTargetVol; - - private float nightTargetVol; - - private void Start() - { - DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this); - mixer.GetFloat("DayEnvVolume", out dayTargetVol); - mixer.GetFloat("NightEnvVolume", out nightTargetVol); - dayTargetVol = Mathf.Pow(10f, dayTargetVol / 20f); - nightTargetVol = Mathf.Pow(10f, nightTargetVol / 20f); - mixer.SetFloat("NightEnvVolume", Mathf.Log10(0.0001f) * 20f); - } - - public void OnDawn_AfterSunrise() - { - } - - public void OnDawn_BeforeSunrise() - { - StopAllCoroutines(); - StartCoroutine(FadeToDay()); - } - - public void OnDusk() - { - StopAllCoroutines(); - StartCoroutine(FadeToNight()); - } - - private IEnumerator FadeToNight() - { - if (EnemySpawner.instance.Wavenumber >= EnemySpawner.instance.waves.Count - 1) - { - MusicManager.instance.PlayMusic(finalNightMusic, nightMusicFadeInTime); - } - else - { - MusicManager.instance.PlayMusic(nightMusic, nightMusicFadeInTime); - } - while (transitionClock < 1f) - { - transitionClock += Time.deltaTime / fadeTime; - mixer.SetFloat("DayEnvVolume", Mathf.Log10(Mathf.Lerp(dayTargetVol, 0.0001f, transitionClock)) * 20f); - mixer.SetFloat("NightEnvVolume", Mathf.Log10(Mathf.Lerp(0.0001f, nightTargetVol, transitionClock)) * 20f); - yield return null; - } - transitionClock = 1f; - mixer.SetFloat("DayEnvVolume", Mathf.Log10(0.0001f) * 20f); - mixer.SetFloat("NightEnvVolume", Mathf.Log10(nightTargetVol) * 20f); - } - - private IEnumerator FadeToDay() - { - MusicManager.instance.PlayMusic(null, nightMusicFadeOutTime); - while (transitionClock > 0f) - { - transitionClock -= Time.deltaTime / fadeTime; - mixer.SetFloat("DayEnvVolume", Mathf.Log10(Mathf.Lerp(dayTargetVol, 0.0001f, transitionClock)) * 20f); - mixer.SetFloat("NightEnvVolume", Mathf.Log10(Mathf.Lerp(0.0001f, nightTargetVol, transitionClock)) * 20f); - yield return null; - } - transitionClock = 0f; - mixer.SetFloat("DayEnvVolume", Mathf.Log10(dayTargetVol) * 20f); - mixer.SetFloat("NightEnvVolume", Mathf.Log10(0.0001f) * 20f); - } -} |
