diff --git a/Assets/Scripts/AudioControl.cs b/Assets/Scripts/AudioControl.cs index 2a8246a..072fd97 100644 --- a/Assets/Scripts/AudioControl.cs +++ b/Assets/Scripts/AudioControl.cs @@ -6,22 +6,47 @@ using UnityEngine.Audio; public class AudioControl : MonoBehaviour { public AudioMixer mixer; - public AudioMixerSnapshot maintheme; - public AudioMixerSnapshot end; + public AudioSource maintheme; public AudioSource gameovers; public AudioSource[] soundeffects; - public enum Sfx { shoot, explosion, mobattack}; + public enum Sfx { shoot, explosion, mobattack }; - private float m_TransitionIn; - private float m_TransitionOut; - private bool endstate; + private const float lvlbgm = 37.879f; + private bool menu; // Use this for initialization void Start() { - m_TransitionIn = 1.2f; - m_TransitionOut = 0.3f; + maintheme.loop = true; + gameovers.loop = true; + maintheme.Play(); + } + + private void Update() + { + if (maintheme.time >= 99.0f) + maintheme.time = lvlbgm; + if (gameovers.time >= 22.85f) + gameovers.time = 3; + } + + public void GameOverBgm() + { + maintheme.Stop(); + gameovers.Play(); + } + + public void MenuBgm() + { + if (gameovers.isPlaying) + gameovers.Stop(); + maintheme.Play(); + } + + public void LevelBgm() + { + maintheme.time = lvlbgm; } public void SfxPlay(int sound) @@ -42,4 +67,15 @@ public class AudioControl : MonoBehaviour { mixer.SetFloat("masterVolume", Mathf.Clamp(nvol, -80f, 20f)); } + + public void SetBgmVolume(float nvol) + { + mixer.SetFloat("bgmVolume", Mathf.Clamp(nvol, -80f, 20f)); + } + + public void SetSfxVolume(float nvol) + { + mixer.SetFloat("sfxVolume", Mathf.Clamp(nvol, -80f, 20f)); + } } + diff --git a/Assets/sound/main(0.5).wav b/Assets/sound/main(0.5).wav new file mode 100644 index 0000000..aafbfc5 Binary files /dev/null and b/Assets/sound/main(0.5).wav differ diff --git a/Assets/sound/main(0.5).wav.meta b/Assets/sound/main(0.5).wav.meta new file mode 100644 index 0000000..f9da932 --- /dev/null +++ b/Assets/sound/main(0.5).wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: c89601ee48d799943a756d1d15cd4954 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: