Beispiel #1
0
    public void PlaySound(SoundEvents i_ID, bool allowInterrupt = false)
    {
        if (logSounds)
        {
            Debug.Log("Playing Sound: " + i_ID.ToString());
        }
        SoundEventData dataForSound;

        if (database.TryGetValue(i_ID, out dataForSound))
        {
            if (dataForSound.isEnabled && dataForSound.clips.Count > 0)
            {
                if (!allowInterrupt && audioSource.isPlaying && lastSoundPlayed == i_ID)
                {
                    return;
                }

                AudioClip clip = dataForSound.clips[Random.Range(0, dataForSound.clips.Count)];
                if (clip)
                {
                    audioSource.PlayOneShot(clip);
                    lastSoundPlayed = i_ID;
                }
            }
        }
    }
Beispiel #2
0
        private void SaveSoundsDataEvent(SoundEvents sound, string lang, string file)
        {
            SoundsDataEvent ev = this.CreateSoundsDataEvent();

            ev.IsEnabled = true;
            ev.ID        = -1;
            ev.File      = this.CreateFileString(lang, file);
            ev.Event     = sound.ToString();
            this.Save(ev);
        }
Beispiel #3
0
 public void PlaySound(SoundEvents sound)
 {
     this.PlaySound(sound.ToString());
 }