Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            // check for exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Game1.Game.Exit();
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
            {
                cleanup();
                returnControl("title");
                return;
            }

            // mute check
            checkForMute();

            // pause check
            if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P))
            {
                allowPause = true;
            }
            if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P))
            {
                paused    ^= true;
                allowPause = false;
                if (paused)
                {
                    //MediaPlayer.Pause();
                    MediaPlayer.Volume /= 4;
                    foreach (PowerUp p in PowerUp.AlivePowerUps)
                    {
                        p.AliveTimer.Stop();
                    }
                    foreach (PowerUp p in isaac.ActivePowerUps)
                    {
                        p.ActiveTimer.Stop();
                    }
                }
                else
                {
                    //MediaPlayer.Resume();
                    MediaPlayer.Volume *= 4;
                    foreach (PowerUp p in PowerUp.AlivePowerUps)
                    {
                        p.AliveTimer.Start();
                    }
                    foreach (PowerUp p in isaac.ActivePowerUps)
                    {
                        p.ActiveTimer.Start();
                    }
                }
            }
            if (paused)
            {
                return;
            }

            //show fps every 1 second
            fpsElapsedTime += gameTime.ElapsedGameTime;
            if (fpsElapsedTime > TimeSpan.FromSeconds(1))
            {
                Game1.Game.Window.Title = "FPS: " + frameCounter;
                fpsElapsedTime         -= TimeSpan.FromSeconds(1);
                frameCounter            = 0;
            }

            isaacHurtAnimation.Update();
            //isaacHurtMove(gameTime);

            spawnPotions(gameTime);
            moveIsaac(gameTime);
            Bullet.moveBullets(gameTime);
            rotatePeanuts(gameTime);
            Fireball.moveFireballs(gameTime);
            rotateFireballs(gameTime);
            Laser2.UpdateLasers(gameTime);
            SeekerSnake.UpdateSeekerSnakes(gameTime);

            checkForPowerUpSpawnExpire(gameTime);

            isaac.CalculateCorners();
            alex.CalculateCorners();
            foreach (Laser2 laser in Laser2.Lasers)
            {
                laser.CalculateCorners();
            }
            foreach (Bullet p in Bullet.Peanuts)
            {
                p.CalculateCorners();
            }

            checkForPowerUpAcquisition();
            acquirePotions();

            isaacShoot(gameTime);

            checkForPeanutHits();

            checkForSledgeHammerUse(gameTime);
            checkForSledgeHammerHits();

            if (checkForIsaacHurt())
            {
                isaacDeath();
                cleanup();
                returnControl("title");
                return;
            }

            if (alex.HP == 0)
            {
                cleanup();
                returnControl("postgame");
                return;
            }

            alex.Update(gameTime, isaac);

            updateHearts();
            shrinkPeanuts(gameTime);
            burnPeanuts(gameTime);
            moveBurningPeanuts(gameTime);

            updateSuperFireballLoopingSound();
        }
Beispiel #2
0
        public override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                (exitButton.Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed))
            {
                Game1.Game.Exit();
            }

            MouseState mouseState = Mouse.GetState();

            /*if (startButton.Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed)
             * {
             *  returnControl("enterbill");
             *  return;
             * }*/
            SimpleButton.UpdateAll(mouseState);
            if (startButton.Triggered)
            {
                cleanup();
                returnControl("enterbill");
                return;
            }
            else if (physicsButton.Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                cleanup();
                returnControl("physics");
                return;
            }

            // mute check
            checkForMute();

            // go to test
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.T) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.E) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.S))
            {
                cleanup();
                returnControl("test");
            }

            // go to shooter level
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.S) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.H) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.T))
            {
                cleanup();
                returnControl("shooter");
            }

            // go to rts
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.R) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.T) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.S))
            {
                cleanup();
                returnControl("rts");
            }

            // skip to act 2
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.S) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.K) &&
                Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.I))
            {
                cleanup();
                returnControl("entercarchase");
            }

            // animate isaac
            int secondsElapsed = (int)(DateTime.Now - startTime).TotalSeconds;

            //if (!isaacAnimation.IsRunning && secondsElapsed != 0 && secondsElapsed % 5 == 0)
            if (!isaacAnimation.IsRunning && secondsElapsed % 5 == 0)
            {
                isaacAnimation.Start();
            }
            isaacAnimation.Update();
        }