IEnumerator RepeatSound(SFXInfo sound, float delay) { while (true) { sound.clip.PlaySound(sfx); yield return(new WaitForSeconds(sound.clip.clip.length + delay)); } }
private void button3_Click(object sender, EventArgs e) { if (listBox2.SelectedIndex != -1) { SFXInfo temp = (SFXInfo)listBox2.SelectedItem; temp.sfx.CreateInstance().Play(); } }
public void StopRepeating(SFXInfo info) { if (repeating_sounds.ContainsKey(info)) { StopCoroutine(repeating_sounds[info]); repeating_sounds.Remove(info); } }
void Play(SFXInfo sound) { if (audiosources[poolidx].isPlaying) { FindNextUnusedSource(); } SetAudioSourceToInfoSettings(audiosources[poolidx], sound); audiosources[poolidx].Play(); }
public void PlaySFX(SFXInfo sfxInfo) { if (sfxInfo.clip == null) { return; } AudioManager.playSFX( this, sfxInfo.clip, sfxInfo.delay, sfxInfo.volume); }
void SetAudioSourceToInfoSettings(AudioSource source, SFXInfo info) { source.clip = info.audio; source.volume = info.volume; source.loop = info.loop; source.pitch = 1; if (info.mixer != null) { source.outputAudioMixerGroup = info.mixer; } }
private void button2_Click(object sender, EventArgs e) { if (listBox2.SelectedIndex != -1) { SFXInfo temp = new SFXInfo(); temp.sfxLoc = sfxLocs[listBox2.SelectedIndex]; temp.sfxName = listBox2.SelectedItem.ToString(); temp.ReloadContent(); temp.sfx.CreateInstance().Play(); } }
public void PlayRepeating(SFXInfo info, float delay = 0) { if (info == null || info.clip == null) { return; } if (repeating_sounds.ContainsKey(info)) { return; } repeating_sounds.Add(info, StartCoroutine(RepeatSound(info, delay))); }
public void Stop(SFXIDS id) //These stops go through the entire list which might be a little cumbersome really. { SFXInfo inf = sfx[id]; for (int i = 0; i < audiosources.Count; i++) { if (audiosources[i].clip == inf.audio) { audiosources[i].Stop(); } } }
private void button1_Click(object sender, EventArgs e) { if (button1.Enabled && listBox2.SelectedIndex != -1) { SFXInfo temp = new SFXInfo(); temp.sfxLoc = sfxLocs[listBox2.SelectedIndex]; temp.sfxName = listBox2.SelectedItem.ToString(); temp.ReloadContent(); MapBuilder.gcDB.AddSFX(temp); ReloadLB1(); } }
public void PlaySfx(SFXInfo info, bool is_once_per_frame = true) { if (info == null || info.clip == null) { return; } if (is_once_per_frame && clips_played_this_frame.Contains(info.clip)) { return; } info.clip.PlaySound(sfx); clips_played_this_frame.Add(info.clip); }
public void Play(SFXIDS sound, bool randomPitch) //This shouldn't be a separate play!!! That's Bad! { SFXInfo s = sfx[sound]; if (audiosources[poolidx].isPlaying) { FindNextUnusedSource(); } SetAudioSourceToInfoSettings(audiosources[poolidx], s); if (randomPitch) { audiosources[poolidx].pitch = Random.Range(0.98f, 1.02f); } audiosources[poolidx].Play(); }
/// <summary> /// Playing Sacred means that it plays without switching which audio source plays the file. This is good for sound effects that play a lot and never at the same time. For example, text beeping. /// </summary> /// <param name="sound"></param> /// <param name="uniqueID"></param> /// <param name="randomPitch"></param> public void PlaySacred(SFXIDS sound, UNIQUESOURCES uniqueID, bool randomPitch = false) { AudioSource source; SFXInfo s = sfx[sound]; if (!sacredsources.ContainsKey(uniqueID)) { //add it source = AddNewAudiosourceToPool(); sacredsources.Add(uniqueID, source); } SetAudioSourceToInfoSettings(sacredsources[uniqueID], s); if (randomPitch) { sacredsources[uniqueID].pitch = Random.Range(0.98f, 1.02f); } sacredsources[uniqueID].Play(); }
private void PlaySFX(SFXInfo sfx) { _audioSource.pitch = Random.Range(sfx.pitchMin, sfx.pitchMax); _audioSource.volume = sfx.volume; _audioSource.PlayOneShot(sfx.audioClip); }
public void PlayRandomFromList(SFXLISTS list) { SFXInfo s = sfxLists[list].list[Random.Range(0, sfxLists[list].list.Count)]; Play(s); }