Esempio n. 1
0
 /// <summary>
 /// Выгрузить из памяти пакеты ресурсов со звуковыми эффектами
 /// </summary>
 private void UnloadSfxPacks()
 {
     foreach (var loadedSfxAssetPack in LoadedSfxAssetPacks)
     {
         LinkedResourceManager.UnloadAssetPack(loadedSfxAssetPack);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Начать воспроизведение фоновой музыки
        /// </summary>
        /// <param name="parMusicAsset">Тип фоновой музыки</param>
        /// <param name="parIsLooped">Зациклить воспроизведение?</param>
        public void PlayBgMusic(EAppMusicAssets parMusicAsset, bool parIsLooped)
        {
            //выгрузим старый ресурс фоновой музыки
            if (PlayingBackgroundMusic != null)
            {
                AppSoundManagerMediator.Send(
                    new SoundManagerMessage(ESoundManagerMessageType.SoundReset, PlayingBackgroundMusic.LinkedAppSoundAsset),
                    AppSoundManagerMediator.ViewSoundManagerColleague);

                while (true)
                {
                    SoundManagerRequestB requestBIsPlaying =
                        new SoundManagerRequestB(ESoundManagerRequestType.IsSoundPlaying,
                                                 PlayingBackgroundMusic.LinkedAppSoundAsset);
                    AppSoundManagerMediator.Request(requestBIsPlaying, AppSoundManagerMediator.ViewSoundManagerColleague);

                    if (!requestBIsPlaying.RequestDataBool)
                    {
                        break;
                    }
                }

                LinkedResourceManager.GetAssetInfo(PlayingBackgroundMusic.LinkedAppSoundAsset.LinkedAssetMetadata,
                                                   out string assetPackName,
                                                   out string assetName);
                if (assetPackName != null && assetName != null)
                {
                    //выгрузка
                    LinkedResourceManager.UnloadAssetPack(assetPackName);
                }
            }

            if (ActualAppModel.GetGameplaySettingsData().IsMusicEnabled)
            {
                //загружаемый новый ресурс фоновой музыки
                if (CurrentAudioLibrary.Music.TryGetValue(parMusicAsset, out AppSoundAsset soundAsset))
                {
                    LinkedResourceManager.GetAssetInfo(soundAsset.LinkedAssetMetadata, out string assetPackName,
                                                       out string assetName);
                    if (assetPackName != null && assetName != null)
                    {
                        //загрузка
                        LinkedResourceManager.LoadAssetPack(assetPackName);

                        //воспроизведение
                        AppSoundManagerMediator.Send(
                            new SoundManagerMessageB(ESoundManagerMessageType.SoundPlay, soundAsset, parIsLooped),
                            AppSoundManagerMediator.ViewSoundManagerColleague);
                        PlayingBackgroundMusic = new PlayingBackgroundMusicData(soundAsset, parMusicAsset);
                    }
                }
            }
        }