rendered paste body class AudioManager
{
private AudioEngine engine;
private WaveBank waveBank;
private SoundBank soundBank;
private Cue cue = null;
private AudioCategory category;
private List<Cue> cueList = new List<Cue>();
private List<AudioCategory> catList = new List<AudioCategory>();
public AudioManager(AudioEngine engine, WaveBank waveBank, SoundBank soundBank)
{
this.engine = engine;
this.waveBank = waveBank;
this.soundBank = soundBank;
}
public void playSound(string name)
{
cue = soundBank.GetCue(name);
cue.Play();
cueList.Add(cue);
cue = null;
}
public void pauseSound(string name)
{
cue = soundBank.GetCue(name);
if (!cue.IsPaused)
cue.Pause();
cue = null;
}
public void resumeSound(string name)
{
cue = soundBank.GetCue(name);
if(cue.IsPaused)
cue.Resume();
cue = null;
}
public void stopAllSound()
{
for (int i = cueList.Count - 1; i >= 0; i--)
{
cueList[i].Stop(AudioStopOptions.AsAuthored);
cueList.RemoveAt(i);
}
}
public void stopOneSound(string name)
{
cue = soundBank.GetCue(name);
if (!cue.IsStopped || !cue.IsStopping)
{
cue.Stop(AudioStopOptions.AsAuthored);
for (int i = cueList.Count - 1; i >= 0; i--)
{
if (cue.Name.ToString() == name)
{
cueList.RemoveAt(i);
return;
}
}
}
cue = null;
}
public void increaseSpeed(string name, float increment)
{
}
public void increaseAllSpeed(float increment)
{
}
public void decreaseSpeed(string name, float volume)
{
}
public void decreaseAllSpeed(float decrement)
{
}
public void setVolume(string category, float volume)
{
this.category = engine.GetCategory(category);
this.category.SetVolume(volume);
if (!catList.Contains(this.category))
catList.Add(this.category);
}
public void setAllUsedVolume(float volume)
{
foreach (AudioCategory cat in catList)
{
cat.SetVolume(volume);
}
}
public void Update()
{
engine.Update();
}
}