예제 #1
0
        public override void Initialize()
        {
            m_SoundSettings = this.Game.Services.GetService(typeof(IGameSettings)) as ISoundSettings;
            createToggleSoundMenuItem(m_SoundSettings.IsMuted());
            createBackgroundMusicVolumeMenuItem();
            createSoundEffectsVolumeMenuItem();
            CreateDoneMenuItem();

            base.Initialize();
        }
예제 #2
0
        public void AddMusicBed(ISoundSettings soundSettings, int position = 0)
        {
            if (soundSettings.Type != SoundType.MusicBed)
            {
                throw new ArgumentException("sound must be a music bed");
            }

            var sound = _soundFactory.Create(soundSettings);

            _musicBeds.Insert(position, sound);
        }
예제 #3
0
        public void AddSoundEffect(ISoundSettings soundSettings, int position = 0)
        {
            if (soundSettings.Type != SoundType.SoundEffect)
            {
                throw new ArgumentException("sound must be a sound effect");
            }

            var sound = _soundFactory.Create(soundSettings);

            _soundEffects.Insert(position, sound);
        }
예제 #4
0
        //add stuff
        public void AddAmbientSound(ISoundSettings soundSettings, int position = 0)
        {
            if (soundSettings.Type != SoundType.AmbientSound)
            {
                throw new ArgumentException("sound must be an ambient sound type");
            }

            var sound = _soundFactory.Create(soundSettings);

            _ambientSounds.Insert(position, sound);
        }
예제 #5
0
        public override void Update(GameTime gameTime)
        {
            bool doUpdate = true;

            switch (this.State)
            {
            case eScreenState.Activating:
            case eScreenState.Deactivating:
            case eScreenState.Closing:
                UpdateTransition(gameTime);
                break;

            case eScreenState.Active:
                break;

            case eScreenState.Inactive:
            case eScreenState.Closed:
                doUpdate = false;
                break;

            default:
                break;
            }

            if (doUpdate)
            {
                base.Update(gameTime);

                ISoundSettings gameSettings = (this.Game.Services.GetService(typeof(IGameSettings)) as ISoundSettings);
                if (gameSettings != null)
                {
                    if (InputManager.KeyPressed(Keys.M))
                    {
                        gameSettings.SetIsMuted(!gameSettings.IsMuted());
                    }
                }

                if (PreviousScreen != null && !this.IsModal)
                {
                    PreviousScreen.Update(gameTime);
                }

                foreach (KeyValuePair <Keys, NamedAction> keyAndAction in m_ActivationKeys)
                {
                    if (InputManager.KeyPressed(keyAndAction.Key))
                    {
                        keyAndAction.Value.Action.Invoke();
                    }
                }
            }
        }
예제 #6
0
        public async Task SaveSoundSettingsAsync(ISoundSettings soundSettings)
        {
            var resolver = new MappedContractResolver();

            resolver.Mapping.Map("Filename").Ignore();

            var json = JsonConvert.SerializeObject(soundSettings, Formatting.Indented, new JsonSerializerSettings()
            {
                ContractResolver = resolver
            });

            var filename = GetFilename(soundSettings);

            await FileAsync.WriteAllTextAsync(filename, json);

            await WriteSoundSettingsToCache(filename, _cache);
        }
예제 #7
0
        public Sound(ISoundSettings soundSettings, ISoundService soundService)
        {
            //first, create the audio track
            AudioTrack = soundService.AudioEngine.AddAudioTrack(soundSettings.AudioFile);

            //set the name as the sound name initially
            Name = soundSettings.Name;

            //need to save the audio file for later
            AudioFile = soundSettings.AudioFile;

            Type = soundSettings.Type;

            //settings for audio track
            AudioTrack.Loop = soundSettings.LoopEnabled;
            AudioTrack.MultipartLoopEnabled = soundSettings.MultipartLoopEnabled;
            AudioTrack.MultipartLoop        = soundSettings.MultipartLoopSettings;
        }
예제 #8
0
        private string GetFilename(ISoundSettings soundSettings)
        {
            var name = $"{GetTypeAbbreviation(soundSettings.Type)}-{soundSettings.Name.ToLower().SpacesToDashes()}";

            var filename = Path.Combine(_path, $"{name}.{FILE_EXTENSION}");

            var index = 1;

            while (File.Exists(filename))
            {
                var indexedName = $"{GetTypeAbbreviation(soundSettings.Type)}-{soundSettings.Name.ToLower().SpacesToDashes()}-{index}";

                filename = Path.Combine(_path, $"{indexedName}.{FILE_EXTENSION}");

                index++;
            }

            return(filename);
        }
예제 #9
0
 public SoundLibraryViewSoundSetting(ISoundSettings soundSettings)
 {
     _soundSettings = soundSettings;
 }
예제 #10
0
 public SoundLibrarySelectedItemChanged(ISoundSettings soundSettings)
 {
     _soundSettings = soundSettings;
 }
예제 #11
0
 private void OnSoundLibrarySelectedItemChanged(ISoundSettings obj)
 {
 }
예제 #12
0
 public void DeleteSoundSettings(ISoundSettings soundSettings)
 {
     throw new NotImplementedException();
 }