Beispiel #1
0
        public MainMenu(Game i_Game, LevelTransitionScreeen i_TransitionScreen, PlayGameScreen i_GameScreen) : base(i_Game, "Main Menu")
        {
            m_TransitionionScreen = i_TransitionScreen;
            m_GameScreen          = i_GameScreen;
            this.AddItem(new MenuItem(Game, this, new SoundOptions(i_Game, this), "Sound Options"));
            this.AddItem(new MenuItem(Game, this, new ScreenOptions(i_Game, this), "Screen Options"));
            ToggleMenuItem TwoPlayers =
                new ToggleMenuItem(Game, this, "Two Players", SpaceInvadersSettings.GetInstance(Game).TwoPlayers);

            TwoPlayers.ValueChanged += TwoPlayersValueChangedHandler;
            this.AddItem(TwoPlayers);
            this.AddItem(new FunctionMenuItem(Game, this, "Play", play));
            this.AddItem(new FunctionMenuItem(Game, this, "Quit", quit));
        }
Beispiel #2
0
        private bool isPlayerDied()
        {
            bool isNoMorePlayers = false;

            if (SpaceInvadersSettings.GetInstance(Game).TwoPlayers)
            {
                isNoMorePlayers = m_Players[0].IsAlive == false && m_Players[1].IsAlive == false;
            }
            else
            {
                isNoMorePlayers = m_Players[0].IsAlive == false;
            }
            return(isNoMorePlayers);
        }
        public SoundOptions(Game i_Game, GameScreen i_Caller) : base(i_Game, "Sound Options")
        {
            PrecentValueMenuItem bgMusicVolume =
                new PrecentValueMenuItem(Game, this, "Background Music Volume", SpaceInvadersSettings.GetInstance(Game).BGMusicVolume);

            bgMusicVolume.ValueChanged += bgMusicVolumeValueChanged;
            this.AddItem(bgMusicVolume);
            PrecentValueMenuItem soundFxVolume =
                new PrecentValueMenuItem(Game, this, "Sound Effects Volume", SpaceInvadersSettings.GetInstance(Game).SoundFXVolume);

            soundFxVolume.ValueChanged += soundFxVolumeValueChanged;
            this.AddItem(soundFxVolume);
            ToggleMenuItem soundOff =
                new ToggleMenuItem(Game, this, "Is Sound Off", SpaceInvadersSettings.GetInstance(Game).IsSoundOff);

            soundOff.ValueChanged += soundOffValueChanged;
            this.AddItem(soundOff);

            this.AddItem(new MenuItem(Game, this, i_Caller, "Done"));
        }
Beispiel #4
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            m_SpriteBatch.Begin();
            m_SpriteBatch.DrawString(
                m_Font,
                string.Format("P1 Score: {0}", m_Players[0].Score),
                Vector2.Zero + new Vector2(5),
                Color.Blue);
            if (SpaceInvadersSettings.GetInstance(Game).TwoPlayers)
            {
                m_SpriteBatch.DrawString(
                    m_Font,
                    string.Format("P2 Score: {0}", m_Players[1].Score),
                    new Vector2(5, 5 + 20),
                    Color.Green);
            }
            m_SpriteBatch.End();
        }
        public ScreenOptions(Game i_Game, GameScreen i_Caller) : base(i_Game, "Screen Options")
        {
            ToggleMenuItem isMouseVisible =
                new ToggleMenuItem(Game, this, "Is Mouse Visible On Screen", SpaceInvadersSettings.GetInstance(Game).IsMouseVisibile);

            isMouseVisible.ValueChanged += mouseValueChanged;
            this.AddItem(isMouseVisible);
            ToggleMenuItem isWindowResizeAllowed =
                new ToggleMenuItem(Game, this, "Is Window Resize Allowed", SpaceInvadersSettings.GetInstance(Game).IsWindowResizeAllowed);

            isWindowResizeAllowed.ValueChanged += windowResizeValueChanged;
            this.AddItem(isWindowResizeAllowed);
            ToggleMenuItem isFullScreen =
                new ToggleMenuItem(Game, this, "Is On Full Screen Mode", SpaceInvadersSettings.GetInstance(Game).IsOnFullScreenMode);

            isFullScreen.ValueChanged += fullScreenValueChanged;
            this.AddItem(isFullScreen);

            this.AddItem(new MenuItem(Game, this, i_Caller, "Done"));
        }
Beispiel #6
0
 protected override void OnActivated()
 {
     base.OnActivated();
     if (!SpaceInvadersSettings.GetInstance(Game).TwoPlayers)
     {
         Remove(m_Players[1]);
         foreach (Soul soul in m_Players[1].Souls)
         {
             Remove(soul);
         }
     }
     else
     {
         if (!this.Contains(m_Players[1]))
         {
             Add(m_Players[1]);
             foreach (Soul soul in m_Players[1].Souls)
             {
                 Add(soul);
             }
         }
     }
 }
 private void soundOffValueChanged(bool i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).IsSoundOff = i_Value;
 }
 private void soundFxVolumeValueChanged(int i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).SoundFXVolume    = i_Value;
     SoundEffectsManager.GetInstance(Game).SoundEffectsVolume = (float)i_Value / 100;
 }
 private void fullScreenValueChanged(bool i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).IsOnFullScreenMode = i_Value;
 }
 private void windowResizeValueChanged(bool i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).IsWindowResizeAllowed = i_Value;
 }
 private void mouseValueChanged(bool i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).IsMouseVisibile = i_Value;
 }
Beispiel #12
0
 private void TwoPlayersValueChangedHandler(bool i_Value)
 {
     SpaceInvadersSettings.GetInstance(Game).TwoPlayers = i_Value;
 }