Esempio n. 1
0
 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();
     }
 }
Esempio n. 3
0
 public void StopRepeating(SFXInfo info)
 {
     if (repeating_sounds.ContainsKey(info))
     {
         StopCoroutine(repeating_sounds[info]);
         repeating_sounds.Remove(info);
     }
 }
Esempio n. 4
0
    void Play(SFXInfo sound)
    {
        if (audiosources[poolidx].isPlaying)
        {
            FindNextUnusedSource();
        }

        SetAudioSourceToInfoSettings(audiosources[poolidx], sound);
        audiosources[poolidx].Play();
    }
Esempio n. 5
0
 public void PlaySFX(SFXInfo sfxInfo)
 {
     if (sfxInfo.clip == null)
     {
         return;
     }
     AudioManager.playSFX(
         this, sfxInfo.clip,
         sfxInfo.delay, sfxInfo.volume);
 }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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();
     }
 }
Esempio n. 8
0
 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)));
 }
Esempio n. 9
0
    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();
            }
        }
    }
Esempio n. 10
0
 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();
     }
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
    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();
    }
Esempio n. 13
0
    /// <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();
    }
Esempio n. 14
0
 private void PlaySFX(SFXInfo sfx)
 {
     _audioSource.pitch  = Random.Range(sfx.pitchMin, sfx.pitchMax);
     _audioSource.volume = sfx.volume;
     _audioSource.PlayOneShot(sfx.audioClip);
 }
Esempio n. 15
0
    public void PlayRandomFromList(SFXLISTS list)
    {
        SFXInfo s = sfxLists[list].list[Random.Range(0, sfxLists[list].list.Count)];

        Play(s);
    }