コード例 #1
0
        public override List <MenuItem> MakeMenu()
        {
            EnterMenuItem soundOptionsMenuItem = new EnterMenuItem(m_Game, "Sound Options", m_GameScreen);

            soundOptionsMenuItem.EnterPressed += SoundOptionsMenuItem_EnterPressed;
            m_MenuItems.Add(soundOptionsMenuItem);

            EnterMenuItem screenOptionsMenuItem = new EnterMenuItem(m_Game, "Screen Options", m_GameScreen);

            screenOptionsMenuItem.EnterPressed += ScreenOptionsMenuItem_EnterPressed;
            m_MenuItems.Add(screenOptionsMenuItem);

            ToggleMenuItem <string, int> playersNumMenuItem = new ToggleMenuItem <string, int>(m_Game, m_GameScreen, new List <string> {
                "One", "Two"
            }, new List <int> {
                1, 2
            }, "Players: ");

            playersNumMenuItem.CorrespondingToggledItem = m_GameSettingsManager.NumOfPlayers;
            playersNumMenuItem.Toggle += numberOfPlayersChanged;
            m_MenuItems.Add(playersNumMenuItem);

            EnterMenuItem play = new EnterMenuItem(m_Game, "Play", m_GameScreen);

            play.EnterPressed += Play_EnterPressed;
            m_MenuItems.Add(play);

            EnterMenuItem quit = new EnterMenuItem(m_Game, "Quit", m_GameScreen);

            quit.EnterPressed += Quit_EnterPressed;
            m_MenuItems.Add(quit);

            return(m_MenuItems);
        }
コード例 #2
0
        public override List <MenuItem> MakeMenu()
        {
            IScreensManager m_ScreensManager = m_Game.Services.GetService(typeof(IScreensManager)) as IScreensManager;
            List <float>    volumeList       = new List <float> {
                0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
            };

            volumeList.Reverse();
            List <float> realVolumeList = new List <float> {
                0, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f
            };

            realVolumeList.Reverse();
            ToggleMenuItem <float, float> changeBackgroundMusicVolumeMenuItem    = new ToggleMenuItem <float, float>(m_Game, m_GameScreen, volumeList, realVolumeList, "Background Music Volume: ");
            ToggleMenuItem <float, float> changeSoundsEffectsMusicVolumeMenuItem = new ToggleMenuItem <float, float>(m_Game, m_GameScreen, volumeList, realVolumeList, "Sounds Effects Volume: ");

            if (!m_SoundsManager.ToggleSound)
            {
                m_SoundsManager.ToggleSound = !m_SoundsManager.ToggleSound;
                changeBackgroundMusicVolumeMenuItem.CorrespondingToggledItem    = m_GameSettingsManager.BackgroundVolume;
                changeSoundsEffectsMusicVolumeMenuItem.CorrespondingToggledItem = m_GameSettingsManager.SoundEffectsVolume;
                m_SoundsManager.ToggleSound = !m_SoundsManager.ToggleSound;
            }
            else
            {
                changeBackgroundMusicVolumeMenuItem.CorrespondingToggledItem    = m_GameSettingsManager.BackgroundVolume;
                changeSoundsEffectsMusicVolumeMenuItem.CorrespondingToggledItem = m_GameSettingsManager.SoundEffectsVolume;
            }

            changeBackgroundMusicVolumeMenuItem.Toggle += backgroundVolumeChanged;
            m_MenuItems.Add(changeBackgroundMusicVolumeMenuItem);

            changeSoundsEffectsMusicVolumeMenuItem.Toggle += soundsEffectsVolumeChanged;
            m_MenuItems.Add(changeSoundsEffectsMusicVolumeMenuItem);

            m_SoundToggleMenuItem.CorrespondingToggledItem = m_GameSettingsManager.MusicToggle;
            m_SoundToggleMenuItem.Toggle += soundToggleChanged;
            m_MenuItems.Add(m_SoundToggleMenuItem);

            EnterMenuItem done = new EnterMenuItem(m_Game, "Done", m_GameScreen);

            done.EnterPressed += Done_EnterPressed;
            m_MenuItems.Add(done);
            return(m_MenuItems);
        }
コード例 #3
0
        public override List <MenuItem> MakeMenu()
        {
            IScreensManager m_ScreensManager = m_Game.Services.GetService(typeof(IScreensManager)) as IScreensManager;

            ToggleMenuItem <string, bool> mouseVisibilityToggleMenuItem = new ToggleMenuItem <string, bool>(m_Game, m_GameScreen, new List <string> {
                "Visible", "Invisible"
            }, new List <bool> {
                true, false
            }, "Mouse Visability: ");

            mouseVisibilityToggleMenuItem.CorrespondingToggledItem = m_GameSettingsManager.MouseVisibility;
            mouseVisibilityToggleMenuItem.Toggle += mouseVisibilityChanged;
            m_MenuItems.Add(mouseVisibilityToggleMenuItem);

            ToggleMenuItem <string, bool> allowResizingToggleMenuItem = new ToggleMenuItem <string, bool>(m_Game, m_GameScreen, new List <string> {
                "Off", "On"
            }, new List <bool> {
                false, true
            }, "Allow Window Resizing: ");

            allowResizingToggleMenuItem.CorrespondingToggledItem = m_GameSettingsManager.AllowWindowResize;
            allowResizingToggleMenuItem.Toggle += allowingWindowResizingChanged;
            m_MenuItems.Add(allowResizingToggleMenuItem);

            ToggleMenuItem <string, bool> fullScreenToggleMenuItem = new ToggleMenuItem <string, bool>(m_Game, m_GameScreen, new List <string> {
                "Off", "On"
            }, new List <bool> {
                false, true
            }, "Full Screen Mode: ");

            fullScreenToggleMenuItem.CorrespondingToggledItem = m_GameSettingsManager.FullScreen;
            fullScreenToggleMenuItem.Toggle += fullScreenToggled;
            m_MenuItems.Add(fullScreenToggleMenuItem);

            EnterMenuItem done = new EnterMenuItem(m_Game, "Done", m_GameScreen);

            done.EnterPressed += Done_EnterPressed;
            m_MenuItems.Add(done);
            return(m_MenuItems);
        }