Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            startScreen = new StartScreen(this, spriteBatch, Content.Load<SpriteFont>("Fonts/Verdana"), Content.Load<Texture2D>("Textures/Backgrounds/TitelScreen"), Content);
            Components.Add(startScreen);
            startScreen.Hide();

            introductionScreen = new IntroductionScreen(this, spriteBatch, Content.Load<Texture2D>("Textures/Backgrounds/Background"), Content);
            Components.Add(introductionScreen);
            introductionScreen.Hide();

            actionScreen = new ActionScreen(this, spriteBatch, Content.Load<Texture2D>("Textures/Backgrounds/Background"), Content);
            Components.Add(actionScreen);
            actionScreen.Hide();
            activeScreen = startScreen;
            activeScreen.Show();

            StartScreen = Content.Load<Song>("Audio/Screens/StartScreen.wav");
            Sewer = Content.Load<Song>("Audio/Screens/Sewer.wav");
        }
Пример #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); }

            if (activeScreen == introductionScreen)
            {
                if (MediaPlayer.State != MediaState.Playing)
                    MediaPlayer.Play(Sewer);

                MediaPlayer.Volume = 0.4f;

                if (introductionScreen.NextScreen)
                {
                    activeScreen.Hide();
                    activeScreen = actionScreen;
                    activeScreen.Show();
                }
            }

            if (activeScreen == startScreen)
            {
                if (MediaPlayer.State != MediaState.Playing)
                    MediaPlayer.Play(StartScreen);

                MediaPlayer.Volume = 0.2f;

                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    if (startScreen.SelectedIndex == 0)
                    {
                        MediaPlayer.Stop();

                        activeScreen.Hide();
                        activeScreen = introductionScreen;
                        activeScreen.Show();
                    }
                    if (startScreen.SelectedIndex == 1)
                    {
                        this.Exit();
                    }
                }
            }
            base.Update(gameTime);
            oldKeyboardState = keyboardState;
        }