Added main(0.5) + some AudioControl
This commit is contained in:
parent
74f2d06be8
commit
3fd5637ec9
3 changed files with 66 additions and 8 deletions
|
@ -6,22 +6,47 @@ using UnityEngine.Audio;
|
||||||
public class AudioControl : MonoBehaviour
|
public class AudioControl : MonoBehaviour
|
||||||
{
|
{
|
||||||
public AudioMixer mixer;
|
public AudioMixer mixer;
|
||||||
public AudioMixerSnapshot maintheme;
|
public AudioSource maintheme;
|
||||||
public AudioMixerSnapshot end;
|
|
||||||
public AudioSource gameovers;
|
public AudioSource gameovers;
|
||||||
public AudioSource[] soundeffects;
|
public AudioSource[] soundeffects;
|
||||||
|
|
||||||
public enum Sfx { shoot, explosion, mobattack};
|
public enum Sfx { shoot, explosion, mobattack };
|
||||||
|
|
||||||
private float m_TransitionIn;
|
private const float lvlbgm = 37.879f;
|
||||||
private float m_TransitionOut;
|
private bool menu;
|
||||||
private bool endstate;
|
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
m_TransitionIn = 1.2f;
|
maintheme.loop = true;
|
||||||
m_TransitionOut = 0.3f;
|
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)
|
public void SfxPlay(int sound)
|
||||||
|
@ -42,4 +67,15 @@ public class AudioControl : MonoBehaviour
|
||||||
{
|
{
|
||||||
mixer.SetFloat("masterVolume", Mathf.Clamp(nvol, -80f, 20f));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
Assets/sound/main(0.5).wav
Normal file
BIN
Assets/sound/main(0.5).wav
Normal file
Binary file not shown.
22
Assets/sound/main(0.5).wav.meta
Normal file
22
Assets/sound/main(0.5).wav.meta
Normal file
|
@ -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:
|
Loading…
Add table
Reference in a new issue