예제 #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);

            lvl1 = new Level1(player);

            effect = Content.Load <SoundEffect>("JUMP");



            // TODO: use this.Content to load your game content here
        }
예제 #2
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);

            lvl1 = new Level1(snowGroundTexture, snowTexture, rainTexture, player, groundBlockTexture, damagesprite, munkSprite, grenSprite, flyingsprite);

            effect     = Content.Load <SoundEffect>("JUMP");
            eatingMunk = Content.Load <SoundEffect>("The Heavy eating his Sandvich");



            // TODO: use this.Content to load your game content here
        }
예제 #3
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)
        {
            //All kod i regonen nedan  alltså mellan de två gröna sträcken är av Kilian
            //===========================================================================================================================
            #region Kilians del i Game1
            // De olika if-satserna  nedan som anroppar de olika "Update" metoderna
            // är till för att när man till exempel spelaren inte ska fortsätta springa runt
            // när man har pausat spelet.


            //Updaterar "testleveln och playern"
            if (gamestates == Gamestates.inGame)
            #region Allt i test level och player
            {
                IsMouseVisible = false;
                gamestates     = lvl1.Update(gameTime, player, effect, eatingMunk);

                camera.Update(player.position);
                lvl1.Update(gameTime, player, effect, eatingMunk);
            }
            #endregion

            //Lämnar spelet
            if (gamestates == Gamestates.exitgame)
            {
                Exit();
            }


            //Updaterar start menyn
            if (gamestates == Gamestates.startmenu)
            {
                IsMouseVisible = true;
                gamestates     = startmenu.Update();
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Delete))
                {
                    Exit();
                }
            }


            //Updaterar level menyn
            if (gamestates == Gamestates.levelmenu)
            {
                IsMouseVisible = true;
                gamestates     = levelMenu.Update(player);
            }


            //Updaterar paus menyn
            if (gamestates == Gamestates.pausemenu)
            {
                IsMouseVisible = true;
                gamestates     = pausemenu.Update();

                if (gamestates == Gamestates.startmenu)
                {
                    //Nollställer lvl1 när man lämnar spelet.
                    lvl1 = new Level1(snowGroundTexture, snowTexture, rainTexture, player, groundBlockTexture, damagesprite, munkSprite, grenSprite, flyingsprite);

                    //Nollställer
                    player = new Player(playerSprite, playerSprite, healthTexture);
                }
            }


            //Updaterar shop menyn
            if (gamestates == Gamestates.shopmenu)
            {
                IsMouseVisible = true;
                gamestates     = shopmenu.Update(player);
            }


            //Updaterar gameover menyn
            if (gamestates == Gamestates.gameOverMenu)
            {
                //Nollställertt lvl1 när man har förlorat.
                lvl1 = new Level1(snowGroundTexture, snowTexture, rainTexture, player, groundBlockTexture, damagesprite, munkSprite, grenSprite, flyingsprite);

                //Nollställer playern när man har förlorat.
                player = new Player(playerSprite, playerSprite, healthTexture);

                IsMouseVisible = true;
                gamestates     = gameOverMenu.Update(player);
            }

            if (gamestates == Gamestates.youWinMenu)
            {
                IsMouseVisible = true;
                gamestates     = youWinMenu.Update();
                //Nollställer lvl1 när man lämnar spelet.
                lvl1 = new Level1(snowGroundTexture, snowTexture, rainTexture, player, groundBlockTexture, damagesprite, munkSprite, grenSprite, flyingsprite);

                //Nollställer
                player = new Player(playerSprite, playerSprite, healthTexture);
            }
            // TODO: Add your update logic here
            base.Update(gameTime);
        }