protected virtual string GetDrawString(ISoundInfo item) { if (item == null) return null; return string.Format("{0}. {1}", item.ID, item.Name); }
protected virtual string GetDrawString(ISoundInfo item) { if (item == null) { return(null); } return(string.Format("{0}. {1}", item.ID, item.Name)); }
/// <summary> /// Initializes a new instance of the <see cref="SoundInstance"/> struct. /// </summary> /// <param name="soundInfo">The sound info.</param> /// <param name="sound">The sound.</param> /// <param name="audioEmitter">The audio emitter.</param> public SoundInstance(ISoundInfo soundInfo, Sound sound, IAudioEmitter audioEmitter) { _sound = sound; _soundInfo = soundInfo; _audioEmitter = audioEmitter; }
/// <summary> /// Attempts to create a <see cref="Sound"/> instance. /// </summary> /// <param name="info">The <see cref="ISoundInfo"/> describing the sound to create.</param> /// <param name="spatialized">True if this is for a spatialized sound; false for a static sound.</param> /// <returns>The <see cref="Sound"/> instance, or null if it failed to be created.</returns> Sound InternalCreateSound(ISoundInfo info, bool spatialized) { // Check for a valid ISoundInfo if (info == null) { if (log.IsInfoEnabled) { log.Info("Could not play sound - was given a null ISoundInfo."); } return(null); } // Get the buffer var buffer = GetSoundBuffer(info.ID); if (buffer == null) { const string errmsg = "Failed to play sound `{0}` - could not load the sound buffer. The sound file may not exist or be corrupt."; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, info); } return(null); } // Create the sound instance Sound snd = null; try { snd = new Sound(buffer); } catch (Exception ex) { const string errmsg = "Failed to create sound `{0}`: {1}"; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, info, ex); } try { if (snd != null) { snd.Dispose(); } } catch (Exception ex2) { const string errmsg2 = "Failed to dispose sound `{0}` that failed to be created: {1}"; if (log.IsWarnEnabled) { log.WarnFormat(errmsg2, info, ex2); } } return(null); } snd.Volume = Volume; snd.Loop = false; if (spatialized) { snd.Attenuation = _soundAttenuation; snd.MinDistance = _soundMinDistance; snd.RelativeToListener = false; } else { snd.RelativeToListener = true; snd.Position = Vector3.Zero; } return(snd); }
/// <summary> /// Attempts to create a <see cref="Sound"/> instance. /// </summary> /// <param name="id">The <see cref="SoundID"/>.</param> /// <param name="spatialized">True if this is for a spatialized sound; false for a static sound.</param> /// <param name="info">When this method returns a non-null object, contains the <see cref="ISoundInfo"/> for the /// <paramref name="id"/>.</param> /// <returns> /// The <see cref="Sound"/> instance, or null if it failed to be created. /// </returns> Sound InternalCreateSound(SoundID id, bool spatialized, out ISoundInfo info) { // Get the sound info info = GetSoundInfo(id); return(InternalCreateSound(info, spatialized)); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <param name="source">The source.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info, IAudioEmitter source) { return(soundManager.Play(info.ID, source)); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <param name="source">The source.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info, Vector2 source) { return(soundManager.Play(info.ID, source)); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info) { return(soundManager.Play(info.ID)); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <param name="source">The source.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info, IAudioEmitter source) { return soundManager.Play(info.ID, source); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <param name="source">The source.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info, Vector2 source) { return soundManager.Play(info.ID, source); }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundManager">The sound manager.</param> /// <param name="info">The <see cref="ISoundInfo"/> to play.</param> /// <returns> /// True if the sound played successfully; otherwise false. /// </returns> public static bool Play(this ISoundManager soundManager, ISoundInfo info) { return soundManager.Play(info.ID); }
/// <summary> /// Attempts to create a <see cref="Sound"/> instance. /// </summary> /// <param name="info">The <see cref="ISoundInfo"/> describing the sound to create.</param> /// <param name="spatialized">True if this is for a spatialized sound; false for a static sound.</param> /// <returns>The <see cref="Sound"/> instance, or null if it failed to be created.</returns> Sound InternalCreateSound(ISoundInfo info, bool spatialized) { // Check for a valid ISoundInfo if (info == null) { if (log.IsInfoEnabled) log.Info("Could not play sound - was given a null ISoundInfo."); return null; } // Get the buffer var buffer = GetSoundBuffer(info.ID); if (buffer == null) { const string errmsg = "Failed to play sound `{0}` - could not load the sound buffer. The sound file may not exist or be corrupt."; if (log.IsWarnEnabled) log.WarnFormat(errmsg, info); return null; } // Create the sound instance Sound snd = null; try { snd = new Sound(buffer); } catch (Exception ex) { const string errmsg = "Failed to create sound `{0}`: {1}"; if (log.IsErrorEnabled) log.ErrorFormat(errmsg, info, ex); try { if (snd != null) snd.Dispose(); } catch (Exception ex2) { const string errmsg2 = "Failed to dispose sound `{0}` that failed to be created: {1}"; if (log.IsWarnEnabled) log.WarnFormat(errmsg2, info, ex2); } return null; } snd.Volume = Volume; snd.Loop = false; if (spatialized) { snd.Attenuation = _soundAttenuation; snd.MinDistance = _soundMinDistance; snd.RelativeToListener = false; } else { snd.RelativeToListener = true; snd.Position = Vector3.Zero; } return snd; }
/// <summary> /// Attempts to create a <see cref="Sound"/> instance. /// </summary> /// <param name="id">The <see cref="SoundID"/>.</param> /// <param name="spatialized">True if this is for a spatialized sound; false for a static sound.</param> /// <param name="info">When this method returns a non-null object, contains the <see cref="ISoundInfo"/> for the /// <paramref name="id"/>.</param> /// <returns> /// The <see cref="Sound"/> instance, or null if it failed to be created. /// </returns> Sound InternalCreateSound(SoundID id, bool spatialized, out ISoundInfo info) { // Get the sound info info = GetSoundInfo(id); return InternalCreateSound(info, spatialized); }