public void OnPlayback() { var selfPlayer = _playerContext.flagSelfEntity; if (null == selfPlayer) { return; } foreach (var player in _playGroup.GetEntities()) { SoundSyncUtil.NewNonLoopSoundFromComponent(player.sound, _playSoundList); for (var i = 0; i < _playSoundList.Count; i++) { var cfg = _soundConfigManager.GetSoundById(_playSoundList[i]); if (null != cfg) { if (Vector3.Distance(player.position.Value, selfPlayer.position.Value) <= cfg.Distance) { _soundEntityFactory.CreateSelfOnlyMoveSound(player.position.Value, player.entityKey.Value, _playSoundList[i], false); } } } SoundSyncUtil.NewLoopSoundFromComponent(player.sound, _playSoundList); for (var i = 0; i < _playSoundList.Count; i++) { _soundEntityFactory.CreateSelfOnlyMoveSound(player.position.Value, player.entityKey.Value, _playSoundList[i], true); } } }
public override Entity CreateSyncSound(Entity entity, SoundConfigItem soundConfig, bool loop) { var playerEntity = entity as PlayerEntity; if (null == playerEntity) { Logger.ErrorFormat("entity {0} is not player or null", entity); } if (loop) { SoundSyncUtil.LoopSoundToComponent((short)soundConfig.Id, playerEntity.sound); } else { SoundSyncUtil.NonLoopSoundToComponent((short)soundConfig.Id, playerEntity.sound); } return(null); }