Exemple #1
0
        /// <summary>
        /// Проигрывается ли сейчас данный звуковой эффект?
        /// </summary>
        /// <param name="parSfxAsset">Тип звукового эффекта</param>
        /// <returns>True, если проигрывается</returns>
        public bool IsSfxPlaying(EAppSfxAssets parSfxAsset)
        {
            if (CurrentAudioLibrary.SoundEffects.TryGetValue(parSfxAsset, out AppSoundAsset soundAsset))
            {
                return(PlayingSfx.Contains(soundAsset));
            }

            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Воспроизвести звуковой эффект
 /// </summary>
 /// <param name="parSfxAsset">Тип звукового эффекта</param>
 /// <param name="parIsLooped">Зациклить воспроизведение?</param>
 public void PlaySfx(EAppSfxAssets parSfxAsset, bool parIsLooped)
 {
     //play sound
     if (ActualAppModel.GetGameplaySettingsData().IsSfxEnabled)
     {
         if (CurrentAudioLibrary.SoundEffects.TryGetValue(parSfxAsset, out AppSoundAsset soundAsset))
         {
             AppSoundManagerMediator.Send(
                 new SoundManagerMessage(ESoundManagerMessageType.SoundPlay, soundAsset),
                 AppSoundManagerMediator.ViewSoundManagerColleague);
             PlayingSfx.Add(soundAsset);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Обновление данных менеджера. Предназначен для вызова каждый кадр в модели.
        /// </summary>
        public void ManagerUpdateStep()
        {
            //обновление состояния проигрывания звуковых эффектов
            for (var i = 0; i < PlayingSfx.Count; i++)
            {
                AppSoundAsset appSoundAsset = PlayingSfx[i];
                //используем запросы для получения данных
                SoundManagerRequestB requestBIsPlaying =
                    new SoundManagerRequestB(ESoundManagerRequestType.IsSoundPlaying, appSoundAsset);
                AppSoundManagerMediator.Request(requestBIsPlaying, AppSoundManagerMediator.ViewSoundManagerColleague);

                SoundManagerRequestB requestBIsPaused =
                    new SoundManagerRequestB(ESoundManagerRequestType.IsSoundPaused, appSoundAsset);
                AppSoundManagerMediator.Request(requestBIsPaused, AppSoundManagerMediator.ViewSoundManagerColleague);


                if (!requestBIsPlaying.RequestDataBool && !requestBIsPaused.RequestDataBool)
                {
                    PlayingSfx.Remove(appSoundAsset);
                    i--;
                }
            }
        }