Example #1
0
        private SoundEntity CreateBaseSoundEntity(SoundConfigItem config)
        {
            var entity = _soundContext.CreateEntity();

            entity.AddEntityKey(new EntityKey(_idGenerator.GetNextEntityId(), (int)EEntityType.Sound));
            entity.AddTimeInfo(_currentTime.CurrentTime + config.Delay);
            entity.AddAssetInfo(config.Asset.AssetName, config.Asset.BundleName);
            return(entity);
        }
Example #2
0
        public virtual Entity CreateNonSyncSound(Entity owner, SoundConfigItem soundConfig, bool loop)
        {
            var player = owner as PlayerEntity;

            if (null == player)
            {
                Logger.ErrorFormat("CreateNonSyncSound failed , owner {0} is not player or null", owner);
                return(null);
            }
            var entity = CreateBaseSoundEntity(soundConfig);

            if (null != entity)
            {
                entity.AddParent(player.entityKey.Value);
            }
            return(entity);
        }
Example #3
0
        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);
        }
        private int PlayOnce(SoundConfigItem soundConfig)
        {
            if (null == soundConfig)
            {
                Logger.Error("sound config to play is null !");
                return(UniversalConsts.InvalidIntId);
            }

            var entity = soundConfig.Sync ?
                         _soundEntityFactory.CreateSyncSound(_playerEntity, soundConfig, false) :
                         _soundEntityFactory.CreateNonSyncSound(_playerEntity, soundConfig, false);
            var soundEntity = entity as SoundEntity;

            if (null == soundEntity)
            {
                return(UniversalConsts.InvalidIntId);
            }
            soundEntity.isPlayOnce = true;
            return(soundEntity.entityKey.Value.EntityId);
        }
Example #5
0
 public override Entity CreateNonSyncSound(Entity owner, SoundConfigItem soundConfig, bool loop)
 {
     return(null);
 }