Ejemplo n.º 1
0
        private void PlaySprayAudio()
        {
            Vector3 position = _contexts.player.flagSelfEntity.position.Value;

            GameAudioMedia.PlayUniqueEventAudio(position, EAudioUniqueId.UI_battle_spray);
            /*_contexts.player.flagSelfEntity.AudioController().PlaySimpleAudio(EAudioUniqueId.UI_battle_spray, false);*/
        }
Ejemplo n.º 2
0
 public static void AttachAudioComponents(Contexts context, PlayerEntity playerEntity)
 {
     GameAudioMedia.Dispose();
     playerEntity.AddPlayerAudio();
     GameModuleManagement.ForceAllocate(playerEntity.entityKey.Value.EntityId,
                                        (PlayerAudioController audioController) => { audioController.Initialize(playerEntity); });
 }
Ejemplo n.º 3
0
        public void OnGamePlay()
        {
            var now = DateTime.Now.Ticks / 10000L;

            foreach (SceneObjectEntity entity in soGroup)
            {
                if (now - entity.bombSound.LastSoundTime >= INTERVAL1)
                {
                    GameAudioMedia.PlayUniqueEventAudio(entity.position.Value, EAudioUniqueId.C4_Alarm);
                    entity.bombSound.LastSoundTime = now;
                }
            }

            foreach (FreeMoveEntity entity in fmGroup)
            {
                var interval = INTERVAL3;
                if (now - entity.bombSound.CreateTime <= 24000L)
                {
                    interval = INTERVAL1;
                }
                else if (now - entity.bombSound.CreateTime <= 30000L)
                {
                    interval = INTERVAL2;
                }

                if (now - entity.bombSound.LastSoundTime >= interval)
                {
                    GameAudioMedia.PlayUniqueEventAudio(entity.position.Value, EAudioUniqueId.C4_Alarm);
                    entity.bombSound.LastSoundTime = now;
                }
            }
        }
Ejemplo n.º 4
0
 public void PlayPullBoltAudio()
 {
     if (!IsHeldSlotEmpty)
     {
         GameAudioMedia.PlayWeaponAudio(HeldConfigId, RelatedAppearence.WeaponHandObject(), (config) => config.PullBolt);
     }
 }
Ejemplo n.º 5
0
        protected override void OnRender(ClientEffectEntity entity)
        {
            var comp = entity.logic;

            if (!entity.assets.IsInitialized)
            {
                entity.assets.IsInitialized = true;
                comp.EffectLogic.Initialize(entity);
                if (entity.hasAudio)
                {
                    var audioEfcType = (AudioClientEffectType)entity.audio.AudioClientEffectType;
                    switch (audioEfcType)
                    {
                    case AudioClientEffectType.BulletHit:
                        GameAudioMedia.PlayHitEnvironmentAudio((AudioGrp_HitMatType)entity.audio.AudioClientEffectArg1, entity.position.Value);
                        break;

                    case AudioClientEffectType.BulletDrop:
                        GameAudioMedia.PlayBulletDropAudio(entity.audio.AudioClientEffectArg1,
                                                           (AudioGrp_FootMatType)entity.audio.AudioClientEffectArg2, entity.position.Value);
                        break;

                    case AudioClientEffectType.ThrowExplosion:
                        GameAudioMedia.PlayEventAudio(entity.audio.AudioClientEffectArg1,
                                                      entity.position.Value);
                        break;
                    }
                }
            }
            else
            {
                comp.EffectLogic.Render(entity);
            }
        }
        private void Initialize(ClientEffectEntity entity)
        {
            entity.assets.IsInitialized = true;
            entity.logic.EffectLogic.Initialize(entity);
            if (entity.hasAudio)
            {
                var audioEfcType = (AudioClientEffectType)entity.audio.AudioClientEffectType;
                switch (audioEfcType)
                {
                // case AudioClientEffectType.WeaponEnvHit:
                //     // GameAudioMedia.PlayHitEnvironmentAudio((AudioGrp_HitMatType)entity.audio.AudioClientEffectArg1,
                //     // entity.audio.AudioClientEffectArg2,entity.position.Value);
                //     // _logger.Info("Real Play Time:"+(_playerContext.flagSelfEntity.time.ClientTime - GlobalConst.BeforeAttackTime));
                //     break;
                case AudioClientEffectType.WeaponPlayerHit:

                    GameAudioMedia.PlayHitPlayerAudio((EBodyPart)entity.audio.AudioClientEffectArg1,
                                                      entity.audio.AudioClientEffectArg2, entity.position.Value);
                    break;

                case AudioClientEffectType.BulletDrop:
                    GameAudioMedia.PlayBulletDropAudio(entity.audio.AudioClientEffectArg1,
                                                       (AudioGrp_FootMatType)entity.audio.AudioClientEffectArg2, entity.position.Value);
                    break;

                case AudioClientEffectType.ThrowExplosion:
                    GameAudioMedia.PlayEventAudio(entity.audio.AudioClientEffectArg1, entity.position.Value);
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        public void OnLoadSucc(BulletEntity bullet, UnityObject unityObj)
        {
            if (null != bullet)
            {
                bullet.AddBulletGameObject(unityObj);
                if (unityObj.AudioMono == null)
                {
                    unityObj.AudioMono = unityObj.AsGameObject.AddComponent <AkGameObj>();
                }

                GameAudioMedia.PlayEventAudio((int)EAudioUniqueId.BulletFly, unityObj.AudioMono as AkGameObj, true);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contexts"></param>
        /// <param name="entity"></param>
        /// <param name="e"></param>
        public override void DoEventClient(Entitas.IContexts contexts, IEntity entity, IEvent e)
        {
            if ((entity as PlayerEntity).isFlagSelf)
            {
                return;
            }

            //  var controller = (entity as PlayerEntity).AudioController();
            AudioEvent audioEvent = e as AudioEvent;

            //     DebugUtil.MyLog("Play event :"+audioEvent.EventType);
            switch (audioEvent.EventType)
            {
            case EEventType.AFootstep:
                GameAudioMedia.PlayFootstepAudio(audioEvent as AudioFootstepEvent);
                break;

            case EEventType.AJumpstep:
                GameAudioMedia.PlayJumpstepAudio(audioEvent as AudioJumpstepEvent);
                break;

            case EEventType.AWeaponFire:
                GameAudioMedia.PlayWeaponFireAudio(audioEvent as AudioWeaponFireEvent);
                break;

            case EEventType.ADefault:
                GameAudioMedia.PlayUniqueEventAudio(audioEvent as AudioDefaultEvent);
                break;

            case EEventType.APullbolt:
                GameAudioMedia.PlayWeaponReloadAudio(audioEvent as AudioPullboltEvent);
                break;

            default:
                break;
            }


            // GameAudioMedium.ProcessWeaponAudio(playerEntity,allContexts,(item)=>item.Fire);
            // if (playerEntity.appearanceInterface.Appearance.IsFirstPerson)
            // {

            // }
            // else
            // {
            ////     GameAudioMedium.PerformOnGunFire();
            // }
        }
Ejemplo n.º 9
0
        private static void AttachAudio(Contexts context, PlayerEntity playerEntity)
        {
            GameAudioMedia.Dispose();
            playerEntity.AddPlayerAudio();
            PlayerAudioControllerBase controller;

            if (SharedConfig.IsServer)
            {
                controller = new ServerPlayerAudioController();
            }
            else
            {
                controller = new ClientPlayerAudioController();
            }
            controller.Initialize(playerEntity, context.session.commonSession.RoomInfo.MapId);
            GameModuleManagement.ForceCache(playerEntity.entityKey.Value.EntityId, controller);
        }
Ejemplo n.º 10
0
        public void SwitchIn(EWeaponSlotType in_slot)
        {
            if (!weaponProcessor.FilterSwitchIn(in_slot))
            {
                weaponInteract.ShowTip(Core.Common.ETipType.NoWeaponInSlot);
                return;
            }

            if (IsHeldBagSlotType(in_slot))
            {
                SameSpeciesSwitchIn(in_slot);
            }
            else
            {
                DrawWeapon(in_slot);
                GameAudioMedia.PlayWeaponAudio(HeldWeaponAgent.ConfigId, RelatedAppearence.WeaponHandObject(), (item) => item.SwitchIn);
            }
        }
Ejemplo n.º 11
0
        public void OnLoadSucc(BulletEntity bullet, UnityObject unityObj)
        {
            if (null != bullet && unityObj != null && unityObj.AsGameObject)
            {
                if (GMVariable.NeedBulletFlyLog)
                {
                    Object res   = UnityEditor.AssetDatabase.LoadAssetAtPath <Object>("Assets/Assets/CoreRes/Sound/Model/Sphere.prefab");
                    var    clone = GameObject.Instantiate(res) as GameObject;
                    unityObj.AsObject = clone;
                }

                bullet.AddBulletAsset(unityObj);
                if (unityObj.AudioMono == null)
                {
                    unityObj.AudioMono = unityObj.AsGameObject.AddComponent <AkGameObj>();
                }
                GameAudioMedia.PlayEventAudio((int)EAudioUniqueId.BulletFly, unityObj.AudioMono as AkGameObj, true);
            }
        }
Ejemplo n.º 12
0
        public void Handle(SimpleProto data)
        {
            if (data.Ks[0] == 0)
            {
                //使用物品声音
                PlayerEntity player = SingletonManager.Get <FreeUiManager>().Contexts1.player.flagSelfEntity;
                if (player != null)
                {
                    var uniqueId = AudioUtil.ToUseItemAudioUniqueId(data.Ins[0]);
                    player.AudioController().PlaySimpleAudio(uniqueId, true);
                }
            }

            if (data.Ks[0] == 1)
            {
                //游戏开始关闭环境音
                MapAmbInfo ambInfo;
                Wwise_IDs.GetMapAmb(data.Ins[0], out ambInfo);
                ambInfo.StopAmb();
            }

            if (data.Ks[0] == 2)
            {
                //播放指定编号的音效
                PlayerEntity player = SingletonManager.Get <FreeUiManager>().Contexts1.player.flagSelfEntity;
                if (player != null)
                {
                    player.AudioController().PlaySimpleAudio((EAudioUniqueId)data.Ins[0], data.Bs[0]);
                }
            }

            if (data.Ks[0] == 3)
            {
                var vc = new Vector3(data.Fs[0], data.Fs[1], data.Fs[2]);
                //在指定位置上播放指定编号的音效
                GameAudioMedia.PlayUniqueEventAudio(vc.ShiftedPosition(), (EAudioUniqueId)data.Ins[0]);
            }
        }
Ejemplo n.º 13
0
        public static void CreateHitEnvironmentEffect(Vector3 hitPoint, Vector3 normal,
                                                      EEnvironmentType environmentType, int hitAudioId,
                                                      bool needEffectEntity, int chunkId, Transform parent = null)
        {
            EffectTypeInfo effectTypeInfo = environmentType.ToClientEfcInfo();

            if (needEffectEntity)
            {
                ClientEffectEmitter clientEffectObj =
                    LocalObjectGenerator.EffectLocal.GetClientEffectEmitter(EEffectObjectClassify.EnvHit);
                IEffectBehavior effectBehavior;
                if (chunkId > 0)
                {
                    var chunkBehavior = ObjectAllocatorHolder <ChunkEffectBehavior> .Allocate();

                    //ChunkEffectBehavior  b1 =ObjectAllocatorHolder<ChunkEffectBehavior>.Allocate();
                    chunkBehavior.Initialize(normal, hitPoint, (int)effectTypeInfo.AudioType, hitAudioId,
                                             AudioClientEffectType.WeaponEnvHit, chunkId, parent);
                    effectBehavior = chunkBehavior;
                }
                else
                {
                    var noramlEffect = ObjectAllocatorHolder <NormalEffectBehavior> .Allocate();

                    //NormalEffectBehavior b2 = ObjectAllocatorHolder<>.Allocate();
                    noramlEffect.Initialize(normal, hitPoint, (int)effectTypeInfo.AudioType, hitAudioId,
                                            AudioClientEffectType.WeaponEnvHit);
                    effectBehavior = noramlEffect;
                }
                clientEffectObj.Initialize((int)effectTypeInfo.DefaultId, effectBehavior);
            }
            else //应对于空手情况
            {
                GameAudioMedia.PlayHitEnvironmentAudio(effectTypeInfo.AudioType, hitAudioId, hitPoint);
            }
        }
Ejemplo n.º 14
0
        public void AnimationEventCallback(PlayerEntity player, string param, UnityEngine.AnimationEvent eventParam)
        {
            if (player.time.ClientTime - _lastTime < StepInterval)
            {
                return;
            }
            _lastTime = player.time.ClientTime;
            if (player.gamePlay.LifeState == (int)EPlayerLifeState.Dead)
            {
                //死亡时不播放行走音效
                return;
            }
            if (player.IsOnVehicle())
            {
                //在车上不播放行走音效
                return;
            }
            switch (player.gamePlay.GameState)
            {
            case GameState.AirPlane:
            case GameState.Gliding:
            case GameState.Invisible:
            case GameState.JumpPlane:
                //以上状态不播放行走音效
                return;

            case GameState.Normal:
            case GameState.Poison:
            case GameState.Visible:
                break;
            }
            var myTerrain          = SingletonManager.Get <TerrainManager>().GetTerrain(SingletonManager.Get <MapConfigManager>().SceneParameters.Id);
            var curPosture         = player.stateInterface.State.GetCurrentPostureState();
            var id                 = UniversalConsts.InvalidIntId;
            var inWater            = SingletonManager.Get <MapConfigManager>().InWater(player.position.Value);
            AudioGrp_Footstep step = AudioGrp_Footstep.None;

            switch (curPosture)
            {
            case PostureInConfig.Crouch:
                if (!inWater)
                {
                    step = AudioGrp_Footstep.Squat;
                }
                break;

            case PostureInConfig.Prone:
                if (!inWater)
                {
                    step = AudioGrp_Footstep.Crawl;
                }
                break;

            case PostureInConfig.Stand:
                if (!inWater)
                {
                    step = AudioGrp_Footstep.Walk;
                }
                break;

            case PostureInConfig.Swim:
                player.soundManager.Value.PlayOnce(EPlayerSoundType.Swim);
                break;

            case PostureInConfig.Dive:
                player.soundManager.Value.PlayOnce(EPlayerSoundType.Dive);
                break;
            }

            if (step != AudioGrp_Footstep.None)
            {
                GameAudioMedia.PlayEnvironmentAudio(step, player.position.Value, player.appearanceInterface.Appearance.CharacterP1);
            }
            //switch (curPosture)
            //{
            //    case PostureInConfig.Crouch:
            //        if(inWater)
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.SquatSwamp);
            //        }
            //        else
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.Squat);
            //        }
            //        break;
            //    case PostureInConfig.Prone:
            //        if(inWater)
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.CrawlSwamp);
            //        }
            //        else
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.Crawl);
            //        }
            //        break;
            //    case PostureInConfig.Stand:
            //        if(inWater)
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.WalkSwamp);
            //        }
            //        else
            //        {
            //            player.soundManager.Value.PlayOnce(EPlayerSoundType.Walk);
            //        }
            //        break;
            //    case PostureInConfig.Swim:
            //        player.soundManager.Value.PlayOnce(EPlayerSoundType.Swim);
            //        break;
            //    case PostureInConfig.Dive:
            //        player.soundManager.Value.PlayOnce(EPlayerSoundType.Dive);
            //        break;
            //}
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contexts"></param>
        /// <param name="entity"></param>
        /// <param name="e"></param>
        public override void DoEventClient(Entitas.IContexts contexts, IEntity entity, IEvent e)
        {
            if (SharedConfig.IsMute)
            {
                return;
            }
            //var controller = (entity as PlayerEntity).AudioController();
            var targetPlayerEntity = entity as PlayerEntity;
            int cmrEntityId        = (contexts as Contexts).player.flagSelfEntity.gamePlay.CameraEntityId;
            // foreach(PlayerEntity playerEntity in (contexts as Contexts).player.GetEntities())
            // {
            //    if(playerEntity.gamePlay.CameraEntityId == player.entityKey.Value.EntityId)
            //     {
            //         //TODO
            //         observePlayer = playerEntity;
            //         break;
            //     }
            // }

            AudioEvent audioEvent = e as AudioEvent;

            //DebugUtil.MyLog("Play other event :"+audioEvent.EventType);
            switch (audioEvent.EventType)
            {
            case EEventType.AFootstep:
                GameAudioMedia.PlayFootstepAudio(audioEvent as AudioFootstepEvent);
                break;

            case EEventType.AJumpstep:
                GameAudioMedia.PlayJumpstepAudio(audioEvent as AudioJumpstepEvent);
                break;

            case EEventType.AWeaponFire:
                GameAudioMedia.PlayWeaponFireAudio(audioEvent as AudioWeaponFireEvent);
                break;

            case EEventType.ADefault:
                if (cmrEntityId == targetPlayerEntity.entityKey.Value.EntityId)
                {
                    float RTPCvalue = 1;
                    GameAudioMedia.PlayUniqueEventAudio(audioEvent as AudioDefaultEvent, RTPCvalue);
                    break;
                }
                else
                {
                    float RTPCvalue = 0;
                    GameAudioMedia.PlayUniqueEventAudio(audioEvent as AudioDefaultEvent, RTPCvalue);
                    break;
                }

            case EEventType.APullbolt:
                GameAudioMedia.PlayWeaponReloadAudio(audioEvent as AudioPullboltEvent);
                break;

            case EEventType.AMeleeAttack:
                GameAudioMedia.PlayMeleeAttackAudio(audioEvent as AudioMeleeAtkEvent);
                break;

            default:
                break;
            }


            // GameAudioMedium.ProcessWeaponAudio(playerEntity,allContexts,(item)=>item.Fire);
            // if (playerEntity.appearanceInterface.Appearance.IsFirstPerson)
            // {

            // }
            // else
            // {
            ////     GameAudioMedium.PerformOnGunFire();
            // }
        }