コード例 #1
0
        protected override void UpdateScreen(GameTime gameTime)
        {
            mouse.Update();

            foreach (var b in musicBlock.Buttons)
            {
                b.Value.Update(gameTime, mouse);
            }

            foreach (var b in soundBlock.Buttons)
            {
                b.Value.Update(gameTime, mouse);
            }

            if (InputMap.NewActionPress("Finished"))
            {
                ExitScreen();
                screenBefore.ActivateScreen();
            }
            if (OptionsState == TowerDefense.OptionsState.Music)
            {
                if (InputMap.NewActionPress("Volume Up") && Settings.MusicVolume < 1.0f)
                {
                    Settings.MusicVolume += 0.05f;
                    AudioManager.singleton.SetVolume("Music", Settings.MusicVolume);
                    musicBlock.GetButton("MusicButton").ButtonText.Value = String.Format("Music:{0}%", (int)(Settings.MusicVolume * 100));
                }

                if (InputMap.NewActionPress("Volume Down") && Settings.MusicVolume > 0)
                {
                    Settings.MusicVolume -= 0.05f;
                    AudioManager.singleton.SetVolume("Music", Settings.MusicVolume);
                    musicBlock.GetButton("MusicButton").ButtonText.Value = String.Format("Music:{0}%", (int)(Settings.MusicVolume * 100));
                }
            }
            else if (OptionsState == TowerDefense.OptionsState.Sound)
            {
                if (InputMap.NewActionPress("Volume Up") && Settings.SoundVolume < 1.0f)
                {
                    Settings.SoundVolume += 0.05f;
                    AudioManager.singleton.SetVolume("Sound", Settings.SoundVolume);
                    soundBlock.GetButton("SoundButton").ButtonText.Value = String.Format("Sound:{0}%", (int)(Settings.SoundVolume * 100));
                    AudioManager.singleton.PlaySound("Hit");
                }

                if (InputMap.NewActionPress("Volume Down") && Settings.SoundVolume > 0)
                {
                    Settings.SoundVolume -= 0.05f;
                    AudioManager.singleton.SetVolume("Sound", Settings.SoundVolume);
                    soundBlock.GetButton("SoundButton").ButtonText.Value = String.Format("Sound:{0}%", (int)(Settings.SoundVolume * 100));
                    AudioManager.singleton.PlaySound("Hit");
                }
            }
        }