本文整理汇总了C#中IContentManager.LoadSoundBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# IContentManager.LoadSoundBuffer方法的具体用法?C# IContentManager.LoadSoundBuffer怎么用?C# IContentManager.LoadSoundBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContentManager
的用法示例。
在下文中一共展示了IContentManager.LoadSoundBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SoundManager
public SoundManager(IContentManager contentManager)
{
// Load the values from file
var values = AudioManager.LoadValues(_fileName, _rootNodeName);
// Create the _infos and _soundBuffers arrays large enough to hold all values
var max = values.Max(x => x.Value);
_infos = new ISoundInfo[max + 1];
_soundBuffers = new SoundBuffer[_infos.Length];
// Populate both collections
foreach (var value in values)
{
var id = new SoundID(value.Value);
var soundInfo = new SoundInfo(value.Key, id);
// Ensure no duplicates
if (_infos[(int)id] != null)
throw new DuplicateKeyException(string.Format("Two or more SoundInfos found with the ID `{0}`!", soundInfo.ID));
if (_infosByName.ContainsKey(soundInfo.Name))
throw new DuplicateKeyException(string.Format("Two or more SoundInfos found with the name `{0}`!",
soundInfo.Name));
// Add
_infosByName.Add(soundInfo.Name, soundInfo);
_infos[(int)soundInfo.ID] = soundInfo;
_soundBuffers[(int)soundInfo.ID] = contentManager.LoadSoundBuffer(
ContentPaths.SoundsFolder + "/" + soundInfo.Name, ContentLevel.GameScreen);
}
}