Ejemplo n.º 1
0
        /// <summary>
        /// Runs the state's logic, collisions, etc
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param
        public override void Update(GameTime gameTime)
        {
            DKTitle.Update(gameTime);


            playButton.Update(gameTime, _mario.Hitbox);
            infoButton.Update(gameTime, _mario.Hitbox);
            exitButton.Update(gameTime, _mario.Hitbox);
            ChangeStateConditions();

            foreach (var sprite in _menuBarrels)
            {
                sprite.Update(gameTime);
            }

            _mario.Update(gameTime);
            _menuKong.Update(gameTime);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the state's logic, collisions, etc
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        public override void Update(GameTime gameTime)
        {
            DKTitle.Update(gameTime);
            joystickRightLeft.Update(gameTime);
            marioWalking.Update(gameTime);

            marioClimbing.Update(gameTime);
            joystickUpDown.Update(gameTime);

            arcadeButtons.Update(gameTime);
            marioJumping.Update(gameTime);

            _mario.Update(gameTime);


            goBackButton.Update(gameTime, _mario.Hitbox);

            ChangeStateConditions();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Runs all the game logic, all the collisions, animations, sounds, etc
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            //If the game isnt over
            if (!gameOver)
            {
                //Pressing any of the upper arcade buttons will return to the menu
                if (Keyboard.GetState().IsKeyDown(Keys.D6) ||
                    Keyboard.GetState().IsKeyDown(Keys.D7) ||
                    Keyboard.GetState().IsKeyDown(Keys.D8) ||
                    Keyboard.GetState().IsKeyDown(Keys.D9) ||
                    Keyboard.GetState().IsKeyDown(Keys.D0) ||
                    Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    GoBackToMenu();
                }

                //Update the game timer which is used for the score
                _gameTimer.Update(gameTime);
                score = _gameTimer.Text;
                int scoreLength = score.Length;
                //All display at least 4 digits
                for (int i = 0; i < 4 - scoreLength; i++)
                {
                    score = "0" + score;
                }


                brick.Update(gameTime);
                foreach (List <Brick> lb in ground.Values)
                {
                    foreach (Brick b in lb)
                    {
                        b.Update(gameTime);
                    }
                }


                BarrelLogic(gameTime);

                foreach (Ladder l in allLadders)
                {
                    l.Update(gameTime);
                }

                stackedBarrels.Update(gameTime);
                _princess.Update(gameTime);

                foreach (GenericSprite marioLives in allLives)
                {
                    marioLives.Update(gameTime);
                }

                _kong.Update(gameTime);
                _mario.Update(gameTime, ground, allLadders, allBarrels);

                MarioBarrelCollision();

                WinCondition();
            }
            else //If the game is over
            {
                if (gameWon) //And you won it
                {
                    //Save your score unless you already did it
                    if (!scoreSaved)
                    {
                        _scoreManager.Add(new Score()
                        {
                            PlayerName = "NONAME",
                            Value      = score,
                        });
                        ScoreManager.Save(_scoreManager);
                        scoreSaved = true;
                    }

                    //Play the win game music
                    gameWonInstance.Play();
                }
                else //Or you lost it
                {
                    //Play the lose game music
                    gameOverInstance.Play();
                }

                //Start a timer and when it reaches 0 go back to the menu
                //Timer's length is equal to the audio length
                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
                timer -= elapsed;
                if (timer < 0)
                {
                    GoBackToMenu();
                }
            }
        }