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(); } } }
public void Play(string sound) { try { SFXIDS sfx = (SFXIDS)System.Enum.Parse(typeof(SFXIDS), sound); Play(sfx); } catch { Debug.Log("sound not found. Did you mispell? " + sound); } }
public void PlayGlitched(SFXIDS sound) //the idea being I can play any sound glitched -- but dunno how it'll work yet. { //int soundChooser = 0; //switch (c) //{ // case 0: // soundChooser = Random.Range(0, noiseSounds.Length + 1); // if (soundChooser == 2) // { // soundChooser += Random.Range(-2, 1); // } // mixer.SetFloat("drymix", Random.Range(0, 1f)); // mixer.SetFloat("wetmix", Random.Range(0, 1f)); // mixer.SetFloat("rate", Random.Range(0, 20)); // mixer.SetFloat("lowpassCut", 22000f); // if (soundChooser < noiseSounds.Length) // { // noiseSounds[soundChooser].Play(); // } // break; // case 1: // soundChooser = Random.Range(0, noiseSounds.Length + 1); // if (soundChooser == 2) // { // soundChooser += Random.Range(-1, 1); // } // mixer.SetFloat("lowpassCut", Random.Range(100f, 20000f)); // if (soundChooser < noiseSounds.Length) // { // noiseSounds[soundChooser].Play(); // } // break; // case 2: // mixer.SetFloat("drymix", Random.Range(0, 1f)); // mixer.SetFloat("wetmix", Random.Range(0, 1f)); // mixer.SetFloat("rate", Random.Range(0, 20)); // mixer.SetFloat("lowpassCut", 22000f); // noiseSounds[2].Play(); // break; //} //if (soundChooser == noiseSounds.Length) //{ // foreach (AudioSource a in noiseSounds) // { // a.Stop(); // } //} //SoundManager.instance.master.SetFloat("volume", -80); }
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(); }
/// <summary> /// NOT IMPLEMENTED! /// </summary> /// <param name="sound"></param> /// <param name="pitch"></param> public void Play(SFXIDS sound, float pitch) //play with a pitch ??? { }
public void Play(SFXIDS sound) //play directly { Play(sfx[sound]); }