Exemple #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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Shared.Stage = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            // instantiate all scenes
            startScene = new StartScene(this, spriteBatch);
            this.Components.Add(startScene);

            actionScene = new ActionScene(this, spriteBatch);
            this.Components.Add(actionScene);

            helpScene = new HelpScene(this, spriteBatch);
            this.Components.Add(helpScene);

            highScoreScene = new HighScoreScene(this, spriteBatch);
            this.Components.Add(highScoreScene);

            aboutScene = new AboutScene(this, spriteBatch);
            this.Components.Add(aboutScene);

            gameOverScene = new GameOverScene(this, spriteBatch);
            this.Components.Add(gameOverScene);

            // show start scene
            startScene.Show();
        }
Exemple #2
0
        private void LoadScenes()
        {
            //Laddar scenes och hämtar all content som behövs
            //Spelet är uppbyggt med "scener" som är olika spellägen
            //Dessa är bland annat startmenyn och själva spelläget
            smallFont              = Content.Load <SpriteFont>("menuSmall");
            largeFont              = Content.Load <SpriteFont>("menuLarge");
            Globals.font           = smallFont;
            startBackgroundTexture = Content.Load <Texture2D>("images/MainMenuFinal");

            //Skapar en startscen där smallfont är fonten som används när man inte har
            //musen över en länk och largefont är för vald font. StartBack.. är scenens
            //bakgrund.
            startScene = new StartScene(this, smallFont, largeFont,
                                        startBackgroundTexture);

            //Samma som ovan
            consoleScene = new ConsoleScene(this, smallFont, largeFont, startBackgroundTexture);

            playingScene = new PlayingScene(this, crossHair, HUD);

            //Components är typ spelets komponenter :O används för att den ska rita ut allt o shit!
            Components.Add(consoleScene);
            Components.Add(startScene);
            Components.Add(playingScene);

            //Visar startscenen
            startScene.Show();
            activeScene = startScene;
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _resources = new Resources(this);

            // Add startScene
            startScene = new StartScene(this, spriteBatch);
            Components.Add(startScene);
            startScene.Show(true);

            // Add playScene
            playScene = new GameScene(this, spriteBatch);
            Components.Add(playScene);
            playScene.Show(false);

            // Add creditsScene
            creditsScene = new CreditsScene(this, spriteBatch);
            Components.Add(creditsScene);
            creditsScene.Show(false);

            // Add helpScene
            helpScene = new HelpScene(this, spriteBatch);
            Components.Add(helpScene);
            helpScene.Show(false);

            // Add highScoreScene
            highScoreScene = new HighScoreScene(this, spriteBatch);
            Components.Add(highScoreScene);
            highScoreScene.Show(false);

            // Create enterSound
            enterSoundIns = this.Content.Load <SoundEffect>("Sounds/enterSound").CreateInstance();

            // Create and play music
            menuMusic = this.Content.Load <Song>("Sounds/pauseMenu");
            MediaPlayer.Play(menuMusic);
        }
Exemple #4
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice);
            Services.AddService(typeof(SpriteBatch), _spriteBatch);

            _audio = new AudioLibrary();
            _audio.LoadContent(this.Content);
            Services.AddService(typeof(AudioLibrary), _audio);

            helpBackgroundTexture = Content.Load<Texture2D>("helpbackground");
            helpForegroundTexture = Content.Load<Texture2D>("helpforeground");
            _helpScene = new HelpScene(this, helpBackgroundTexture, helpForegroundTexture);
            Components.Add(_helpScene);

            // Create the Start scene
            smallFont = Content.Load<SpriteFont>("menuSmall");
            largeFont = Content.Load<SpriteFont>("menuLarge");
            startBackgroundTexture = Content.Load<Texture2D>("startBackground");
            startElementsTexture = Content.Load<Texture2D>("startSceneElements");
            _startScene = new StartScene(this, smallFont, largeFont, startBackgroundTexture, startElementsTexture);
            Components.Add(_startScene);
            _creditScene = new CreditScene(this, smallFont, largeFont, startBackgroundTexture, startElementsTexture);
            Components.Add(_creditScene);

            actionElementsTexture = Content.Load<Texture2D>("rockrainenhanced");
            actionBackgroundTexture = Content.Load<Texture2D>("spacebackground");
            scoreFont = Content.Load<SpriteFont>("score");
            scoreFont = Content.Load<SpriteFont>("score");
            //_actionScene = new ActionScene(this, actionElementsTexture, actionBackgroundTexture, _scoreFont);
            //Components.Add(_actionScene);

            _joinScene = new JoinScene(this, largeFont, menuControllers);
            Components.Add(_joinScene);
            _startScene.Show();
            _activeScene = _startScene;
        }
Exemple #5
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)
        {
            // TODO: Add your update logic here
            int           selectedIdx = 0;
            KeyboardState ks          = Keyboard.GetState();

            // manage menus & scenes
            if (startScene.Enabled)
            {
                if (oldState.IsKeyDown(Keys.Enter) && ks.IsKeyUp(Keys.Enter))
                {
                    selectedIdx = startScene.Menu.SelectedIdx;
                    startScene.Hide();
                    if (selectedIdx == (int)MainMenu.Start)
                    {
                        actionScene.Show();
                    }
                    else if (selectedIdx == (int)MainMenu.Help)
                    {
                        helpScene.Show();
                    }
                    else if (selectedIdx == (int)MainMenu.HighScore)
                    {
                        RebootHighScoreScene();
                        highScoreScene.Show();
                    }
                    else if (selectedIdx == (int)MainMenu.About)
                    {
                        aboutScene.Show();
                    }
                    else if (selectedIdx == (int)MainMenu.Quit)
                    {
                        Exit();
                    }
                }
            }
            if (actionScene.Enabled)
            {
                if (actionScene.ShowGameOver)
                {
                    actionScene.Enabled = false;
                    gameOverScene.Score = (int)actionScene.Score;
                    highScorePlayers    = ReadScores(); // read scores

                    // if there are players saved and the current score is lower compared to the highest one,
                    // set highscore to this max one;
                    // otherwise set to the current score
                    if (highScorePlayers.Any() && gameOverScene.Score < highScorePlayers[0].Score)
                    {
                        gameOverScene.HighScore = highScorePlayers[0].Score;
                    }
                    else
                    {
                        gameOverScene.HighScore = (int)actionScene.Score;
                    }
                    gameOverScene.Show();
                }
            }
            if (helpScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    helpScene.Hide();
                    startScene.Show();
                }
            }
            if (highScoreScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    highScoreScene.Hide();
                    startScene.Show();
                }
            }
            if (aboutScene.Enabled)
            {
                if (ks.IsKeyDown(Keys.Escape))
                {
                    aboutScene.Hide();
                    startScene.Show();
                }
            }
            if (gameOverScene.Enabled && !gameOverScene.IsEditNameMode)
            {
                if (oldState.IsKeyDown(Keys.Enter) && ks.IsKeyUp(Keys.Enter))
                {
                    selectedIdx = gameOverScene.Menu.SelectedIdx;

                    gameOverScene.Hide();

                    Player player = new Player(gameOverScene.Name, gameOverScene.Score);
                    UpdateScores(player); // update the 'scores' file

                    if (selectedIdx == (int)GameOverMenu.PlayAgain)
                    {
                        actionScene.Hide();
                        RebootActionScene();
                        actionScene.Show();
                    }
                    else if (selectedIdx == (int)GameOverMenu.MainMenu)
                    {
                        gameOverScene.Menu.SelectedIdx = 0;
                        actionScene.Hide();
                        //RebootGameOverScene();
                        RebootActionScene();
                        startScene.Show();
                    }
                }
            }
            oldState = ks;

            base.Update(gameTime);
        }
Exemple #6
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)
        {
            // Whether to exit the game or not upon the press of Esc
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) && oldState.IsKeyUp(Keys.Escape))
            {
                if (playScene.Enabled || creditsScene.Enabled || helpScene.Enabled || highScoreScene.Enabled)
                {
                    HideAllScenes();
                    startScene.Show(true);
                }
                else
                {
                    Exit();
                }
            }

            // TODO: Add your update logic here


            var ks = Keyboard.GetState();

            //Changing to a Scene depending on menu choice
            if (startScene.Enabled || ForcefulSceneChange != 0)
            {
                var selectedIndex = startScene.Menu.SelectedIndex;
                if (ks.IsKeyDown(Keys.Enter) && oldState.IsKeyUp(Keys.Enter) || ForcefulSceneChange != 0)
                {
                    if (ForcefulSceneChange != 0)
                    {
                        selectedIndex       = ForcefulSceneChange;
                        ForcefulSceneChange = 0;
                    }
                    switch (selectedIndex)
                    {
                    case 0:
                        HideAllScenes();
                        playScene.Show(true);
                        enterSoundIns.Play();
                        break;

                    case 1:
                        HideAllScenes();
                        Components.Remove(playScene);
                        Components.Add(playScene = new GameScene(this, spriteBatch));
                        playScene.Show(true);
                        enterSoundIns.Play();

                        MediaPlayer.Play(menuMusic);
                        break;

                    case 2:
                        HideAllScenes();
                        helpScene.Show(true);
                        enterSoundIns.Play();
                        break;

                    case 3:
                        HideAllScenes();
                        highScoreScene.Show(true);
                        enterSoundIns.Play();
                        highScoreScene.ReadFromFile();
                        break;

                    case 4:
                        HideAllScenes();
                        creditsScene.Show(true);
                        enterSoundIns.Play();
                        break;

                    case 5:
                        Exit();
                        break;
                    }
                }
            }
            oldState = ks;

            base.Update(gameTime);
        }