Beispiel #1
0
        public SpaceInvadersGame()
        {
            Content.RootDirectory = "Content";
            LevelTransitionScreen levelTransitionScreen = new LevelTransitionScreen(this);
            PlayScreen            playScreen            = new PlayScreen(levelTransitionScreen, this);
            ScreensManager        screensManager        = new ScreensManager(this);

            screensManager.Push(new GameOverScreen(playScreen, this));
            screensManager.Push(playScreen);
            screensManager.Push(levelTransitionScreen);
            screensManager.SetCurrentScreen(new WelcomeScreen(this));
            this.IsMouseVisible = true;
        }
 private void resetToMainMenu()
 {
     RemoveScores();
     SettingsManager.IsGoToMainMenu = true;
     ScreensManager.Push(new SpaceInvadersGameScreen(Game as GameStructure));
     ScreensManager.SetCurrentScreen(new WelcomeScreen(Game as GameStructure));
 }
        public SpaceInvaders()
        {
            m_Graphics = new GraphicsDeviceManager(this);
            m_Graphics.PreferredBackBufferWidth  = GameSettings.sr_DefaultScreenWidth;
            m_Graphics.PreferredBackBufferHeight = GameSettings.sr_DefaultScreenHeight;
            Content.RootDirectory = "Content";
            m_ScreensMananger     = new ScreensManager(this);
            m_ScreensMananger.GraphicsDeviceManager = m_Graphics;
            m_ScreensMananger.Push(new GameOverScreen(this));
            m_ScreensMananger.Push(new PlayScreen(this));
            m_ScreensMananger.Push(new TransitionScreen(this, 1));
            m_ScreensMananger.SetCurrentScreen(new WelcomeScreen(this));
            InputManager      inputManager     = new InputManager(this);
            CollisionsManager collisionManager = new CollisionsManager(this);
            SoundManager      soundManager     = new SoundManager(this);

            soundManager.InitSoundEffects(GameSettings.s_SoundEffectsNames.Values.ToList(), GameSettings.s_BackgroundSoundName);
            soundManager.InitDefaultVolumes(GameSettings.sr_DefaultBGVolume, GameSettings.sr_DefaultSoundEffectVolume);
            IsMouseVisible = true;
        }
Beispiel #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (InputManager.KeyPressed(Keys.Escape))
            {
                Game.Exit();
            }
            else if (InputManager.KeyPressed(Keys.Enter))
            {
                ScreensManager.Push(new PlayScreen(Game));
                ScreensManager.SetCurrentScreen(new NextLevelScreen(Game, 0));
            }
            else if (InputManager.KeyPressed(Keys.T))
            {
                ScreensManager.SetCurrentScreen(new MainMenu(Game));
            }
        }
Beispiel #5
0
        public MainMenu(Game i_Game) : base(i_Game, "Main menu")
        {
            ToggleMenuItem playersItem = new ToggleMenuItem(i_Game, "Players: ", new Vector2(100, 100), m_GameSettings.NumOfPlayers == 2, "Two", "One", m_ActiveMenuItemColor, m_InactiveMenuItemColor);

            playersItem.ValueChanged += new Action <bool>((i_Value) => m_GameSettings.NumOfPlayers = i_Value ? 2 : 1);
            AddMenuItem(playersItem);
            AddMenuItem(new ActionMenuItem(i_Game, "Screen Settings", new Vector2(100, 120), new Action(() => ScreensManager.SetCurrentScreen(new ScreenSettingsScreen(i_Game))), m_ActiveMenuItemColor, m_InactiveMenuItemColor));
            AddMenuItem(new ActionMenuItem(i_Game, "Sound Settings", new Vector2(100, 140), new Action(() => ScreensManager.SetCurrentScreen(new SoundSettingsScreen(i_Game))), m_ActiveMenuItemColor, m_InactiveMenuItemColor));
            AddMenuItem(new ActionMenuItem(i_Game, "Play", new Vector2(100, 160), new Action(() => { ScreensManager.Push(new PlayScreen(i_Game)); ScreensManager.SetCurrentScreen(new NextLevelScreen(i_Game, 0)); }), m_ActiveMenuItemColor, m_InactiveMenuItemColor));
            AddMenuItem(new ActionMenuItem(i_Game, "Quit", new Vector2(100, 180), new Action(() => i_Game.Exit()), m_ActiveMenuItemColor, Color.White));
        }