예제 #1
0
        private static void Play(float volume, EnhancedSoundEffect sound)
        {
            foreach (var psi in soundList)
            {
                if (psi.Priority > sound.Priority)
                {
                    return;
                }
            }

            var soundInstance = sound.CreateSoundInstance();

            if (soundInstance == null)
            {
                return;
            }

            soundInstance.Volume = volume;

            var prioritizedSoundInstance = new PrioritizedSoundInstance(
                soundInstance, sound.Priority, sound.PriorityDecayRate);

            soundInstance.Play();
            soundList.Add(prioritizedSoundInstance);
        }
예제 #2
0
        /// <summary>
        /// Plays a sound.
        /// </summary>
        /// <param name="sound">The sound to play.</param>
        public static void Play(EnhancedSoundEffect sound)
        {
            if (soundList == null)
            {
                return;
            }

            Play(Volume, sound);
        }
예제 #3
0
 /// <summary>
 /// Plays a sound with the specified volume.
 /// </summary>
 /// <param name="volume">The volume that the sound will be played at.</param>
 /// <param name="sound">The sound to play.</param>
 public static void PlayWithVolume(float volume, EnhancedSoundEffect sound)
 {
     Play(volume, sound);
 }