You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
using System.Collections.Generic;
|
|
using System.IO;
|
|
using CoreGame;
|
|
using Entitas;
|
|
using Framw.AudioFramework;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class AudioPlaySystem : ReactiveSystem<CombatEntity>
|
|
{
|
|
private IGroup<CombatEntity> m_AudioPlayProxyGroup;
|
|
|
|
public AudioPlaySystem(Contexts contexts) : base(contexts.combat)
|
|
{
|
|
// m_AudioPlayProxyGroup = contexts.combat.GetGroup(CombatMatcher.Audio);
|
|
}
|
|
|
|
protected override ICollector<CombatEntity> GetTrigger(IContext<CombatEntity> context)
|
|
{
|
|
return context.CreateCollector(CombatMatcher.Audio);
|
|
}
|
|
|
|
protected override bool Filter(CombatEntity entity)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected override void Execute(List<CombatEntity> entities)
|
|
{
|
|
for (int i = 0; i < entities.Count; i++)
|
|
{
|
|
var audio = entities[i].audio;
|
|
while (audio != null && audio.audioDatas.Count > 0)
|
|
{
|
|
var audioData = audio.audioDatas.Dequeue();
|
|
var tbSound = SoundDescMgr.Instance.GetConfig(audioData.soundId);
|
|
if(tbSound == null)
|
|
continue;
|
|
|
|
if (audioData.isStop && audioData.soundIndex != 0)
|
|
{
|
|
SoundManager.Instance.StopLoop(audioData.soundIndex);
|
|
audio.audioLoopIndexes.Remove(audioData.soundIndex);
|
|
continue;
|
|
}
|
|
|
|
if (audioData.isLoop)
|
|
{
|
|
audioData.soundIndex = SoundManager.Instance.PlayLoop(tbSound.path);
|
|
audio.audioLoopIndexes.Add(audioData.soundIndex);
|
|
}
|
|
else
|
|
{
|
|
audioData.soundIndex = SoundManager.Instance.PlayOneShot(tbSound.path);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|