private void AdjustEffect(BasicSoundEffect effect) { Rect visibleRectange = m_getVisibleRectangleDelegate(); if (effect.Position.HasValue) { effect.SoundVolumeMultiplier = m_volumeEsimationFunction(visibleRectange, effect.Position.Value); } }
public BasicSoundEffect CreateBasicSoundEffect(string relativeSoundName, bool createGCRootToPreventGCWhilePlay = true) { string path = string.Format("Sounds/{0}", relativeSoundName); var effect = new BasicSoundEffect(m_game.Content.Load <SoundEffect>(path).CreateInstance()); RegisterWeak(effect); if (createGCRootToPreventGCWhilePlay) { RegisterHard(effect); } return(effect); }
/// <summary> /// Create GC root to prevent GC /// </summary> private void RegisterHard(BasicSoundEffect effect) { m_soundHardLinks.Add(effect); }
/// <summary> /// Only registered sounds will be controlled by Manager /// </summary> private void RegisterWeak(BasicSoundEffect effect) { m_registeredSounds.Add(new WeakReference(effect)); AdjustEffect(effect); }