public AudioClip GetRandomSound(SoundType soundType) { AudioPlayerClipCollectionData soundData = _soundMap[soundType]; int soundIndex = Random.Range(0, soundData._clips.Length); return(soundData._clips[soundIndex]); }
public void PlayRandomSound(float volume, SoundType soundType, float delay = 0f) { // get sound info AudioPlayerClipCollectionData soundData = _soundMap[soundType]; volume *= soundData._volume; var clip = GetRandomSound(soundType); if (soundData._music) { // play music sound StartCoroutine(PlaySoundClip(volume, clip, soundType, true, delay, null, true, 1f, 0f)); } else { // play normal sound StartCoroutine(PlaySoundClip(volume, clip, soundType, soundData._looping, delay, null, false, 1f, 0f)); } }
public void PlayFirstSound(float volume, SoundType soundType, float delay = 0f, System.Action <AudioSource> sourceCb = null, float pitch = 1f, float jumpToTimeInClip = 0f) { // get sound info //Debug.Log(soundType); AudioPlayerClipCollectionData soundData = _soundMap[soundType]; volume *= soundData._volume; var clip = soundData._clips[0]; if (soundData._music) { // play music sound StartCoroutine(PlaySoundClip(volume, clip, soundType, true, delay, sourceCb, true, pitch, jumpToTimeInClip)); } else { // play normal sound StartCoroutine(PlaySoundClip(volume, clip, soundType, soundData._looping, delay, sourceCb, false, pitch, jumpToTimeInClip)); } }