public void ForcePlaySoundLong(SoundEffect sound, LongSoundOwner owner) { if (owner == LongSoundOwner.None) { throw new ArgumentOutOfRangeException("owner", "LongSoundOwner cannot be set to None."); } if (this._PlayingSoundLong == null && this._PlayingSoundLong.State == SoundState.Playing) { this._PlayingSoundLong.Stop(); this._PlayingSoundLong.Dispose(); } this._PlayingSoundLong = sound.CreateInstance(); this._PlayingSoundLong.Play(); this.LongSoundOwner = owner; }
public bool TryPlaySoundLong(SoundEffect sound, LongSoundOwner owner) { if (owner == LongSoundOwner.None) { throw new ArgumentOutOfRangeException("owner", "LongSoundOwner cannot be set to None."); } if (this._PlayingSoundLong == null) { // Slot empty: add and play. this._PlayingSoundLong = sound.CreateInstance(); this._PlayingSoundLong.Play(); this.LongSoundOwner = owner; return(true); } else { return(false); } }
private void HandleShapeAndSound(SoundService soundService, ShapeAndSoundTuple shapeAndSound, SoundAction soundAction, LongSoundOwner longSoundOwner) { if (shapeAndSound != null) { if (shapeAndSound.Shape != null && !this._BabyShapes.Components.Contains(shapeAndSound.Shape)) { this._BabyShapes.Components.Add(shapeAndSound.Shape); } if (shapeAndSound.Sound != null) { if (soundAction == SoundAction.Button) { soundService.TryPlaySoundButton(shapeAndSound.Sound); } else if (soundAction == SoundAction.Analogue) { soundService.TryPlaySoundLong(shapeAndSound.Sound, longSoundOwner); } else if (soundAction == SoundAction.ForceButton) { soundService.ForcePlaySoundButton(shapeAndSound.Sound); } else if (soundAction == SoundAction.ForceAnalogue) { soundService.TryPlaySoundLong(shapeAndSound.Sound, longSoundOwner); } else { throw new ApplicationException("Forgot a soundType."); } } } }