private Sound RequestFreeSource(int categoryID) { for (int i = 0; i < _sources.Length; ++i) { if (_sources[i].sound.Status == SoundStatus.Stopped) { Source freeSource = _sources[i]; if (categoryID == AudioCategory.NONE) { return(freeSource.sound); } else { AudioCategory category = _categories[categoryID]; if (category.maxInstances < 0) { return(freeSource.sound); } int playingCount = GetUsedSourcesCount(categoryID); if (playingCount < category.maxInstances) { return(freeSource.sound); } } } } return(null); }
public AudioCategory AddCategory(int ID) { while (_categories.Count <= ID) { _categories.Add(new AudioCategory()); } AudioCategory category = new AudioCategory(); _categories.Add(category); return(category); }