예제 #1
0
        public void SetupControls()
        {
            LoadSounds();

            cmbDifficulty.DataSource = new BindingSource(Enum.GetNames(typeof(GameDifficultyTypes)), null);

            btnClearScores.Click += (o, args) =>
            {
                if (MessageBox.Show(this, "Are you sure you want to clear all high scores?", "Clear High Scores", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    ClearHighScores();
                }
            };

            btnSave.Click += (o, args) =>
            {
                SaveSettings();
                Close();
            };

            btnCancel.Click += (o, args) => Close();

            cmbDifficulty.SelectedValueChanged += (o, e) => { OnSettingsChanged?.Invoke(cmbDifficulty); };

            txtPlayerName.TextChanged += (o, e) => OnSettingsChanged?.Invoke(txtPlayerName);

            tbBGMVolume.ValueChanged += (o, e) =>
            {
                OnSettingsChanged?.Invoke(tbBGMVolume);
                MusicManager.BGMVolume = tbBGMVolume.Value / 100f;
            };

            tbSFXVolume.ValueChanged += (o, e) =>
            {
                OnSettingsChanged?.Invoke(tbSFXVolume);
                MusicManager.SFXVolume = tbSFXVolume.Value / 100f;
            };

            tbSFXVolume.MouseUp += (o, e) => {
                var rndSound = _sounds.ElementAt(_rnd.Next(_sounds.Count()));
                MusicManager.GetSound(rndSound).Play();
            };

            lnkLoadDefaults.Click += (o, e) => LoadFromSettings(new AppSettings());

            // Always make sure we apply the latest changes when leaving settings
            FormClosing += (o, e) => LoadFromSettings(AppSettings.Load());
        }
예제 #2
0
        void HitSound()
        {
            var rndSound = _sounds.ElementAt(_gameRNG.Next(_sounds.Count()));

            MusicManager.GetSound(rndSound).Play();
        }