Update() private method

private Update ( ) : void
return void
Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            if (Background != null)
            {
                Background.Update(gameTime);
            }
            var temp = Input.Joystick.Y;

            if (temp < 0 && inputDelay < 0)
            {
                MoveUp();
                inputDelay = 0.15f;
            }
            else if (temp > 0 && inputDelay < 0)
            {
                MoveDown();
                inputDelay = 0.15f;
            }

            if (Input.Fire)
            {
                viewEvent = interactives.First(b => b.IsActive).Event;
            }
            else if (Input.Pause && BackEvent.Event != ViewEvent.None.Event)
            {
                viewEvent = BackEvent;
            }
            else
            {
                viewEvent = ViewEvent.None;
            }

            inputDelay -= gameTime.ElapsedGameTime.Milliseconds / 1000f;
        }
Exemplo n.º 2
0
    public void Update()
    {
        switch (state)
        {
        case GameState.LOADING:
        {
            if (loadingTask.IsCompleted)
            {
                state = GameState.GAME;
            }
        } break;

        case GameState.GAME:
        {
            bg.Update();
            level.Update();

            if (Input.wasPressed(Key.Q))
            {
                Console.WriteLine("Eyo");
                level = Levels.CreateLevel1();
                level.AddEntity(new Player(bg));
            }
        } break;
        }
    }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime, bool otherSceneHasFocus, bool coveredByOtherScene)
        {
            base.Update(gameTime, otherSceneHasFocus, coveredByOtherScene);
            GlobalsVar.Camera.Update();

            foreach (Tower tower in towers)
            {
                tower.Update(gameTime);
            }

            target.Update(gameTime);

            if (IsActive)
            {
                gameBackground.Update();
                GlobalsVar.Map.Update(gameTime);
                foreach (Mob mob in GlobalsVar.Mobs)
                {
                    mob.Update(gameTime);
                }
                gameInterface.Update();
            }

            lastPopMobTimer = lastPopMobTimer.Add(gameTime.ElapsedGameTime);

            if (popMobTimer <= lastPopMobTimer)
            {
                GlobalsVar.Mobs.Add(new PonyStarkMob(new Vector3(0, 2 * 5, 0)));
                lastPopMobTimer = new TimeSpan(0, 0, 0);
            }
        }
Exemplo n.º 4
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)
        {
            //check for input
            background.Update(gameTime);
            //get input
            float[] R = new float[9];
            SensorManager.GetRotationMatrix(R, null, Activity1.accelValues, Activity1.magnetoValues);
            float[] orientation = new float[9];
            SensorManager.GetOrientation(R, orientation);
            float roll = (float)Java.Lang.Math.ToDegrees(orientation[2]);

            touchCollection = TouchPanel.GetState();
            TouchLocation[] touches = new TouchLocation[touchCollection.Count];
            for (int i = 0; i < touchCollection.Count; i++)
            {
                touches[i] = new TouchLocation(touchCollection[i].Id, touchCollection[i].State, touchCollection[i].Position * Game1.screenSize / new Vector2(Window.ClientBounds.Width, Window.ClientBounds.Height));
            }

            switch (state)
            {
            case GameState.Start:
                startScreen.Update(touches, Window);
                break;

            case GameState.Playing:
                level.Update(gameTime, touches, roll);
                pauseScreen.Update(touches, Window);
                break;

            case GameState.End:
                endScreen.Update(touches, Window); break;
            }
        }
Exemplo n.º 5
0
        public override void Update(GameTime gameTime)
        {
            //if (scrolling1.rectangle.X + scrolling1.texture.Width <= 0)
            //{
            //    scrolling1.rectangle.X = scrolling2.rectangle.X + scrolling2.texture.Width;
            //}

            //if (scrolling2.rectangle.X + scrolling2.texture.Width <= 0)
            //{
            //    scrolling2.rectangle.X = scrolling1.rectangle.X + scrolling1.texture.Width;
            //}

            //if (scrolling1.rectangle.X >= scrolling1.rectangle.Width)
            //{
            //    scrolling1.rectangle.X = scrolling2.rectangle.X - scrolling2.texture.Width;
            //}

            //if (scrolling2.rectangle.X >= scrolling2.rectangle.Width)
            //{
            //    scrolling2.rectangle.X = scrolling1.rectangle.X - scrolling1.texture.Width;
            //}

            //if (Keyboard.GetState().IsKeyDown(Keys.Left))
            //{
            scrolling1.Update(-1);
            scrolling2.Update(-1);
            //}
            //if (Keyboard.GetState().IsKeyDown(Keys.Right))
            //{
            //    scrolling1.Update(-1);
            //    scrolling2.Update(-1);
            //}
            base.Update(gameTime);
        }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            World.Step(gameTime.ElapsedGameTime.Milliseconds * 1e-3f);
            Debug.Update(gameTime);
            Background.Update(gameTime);
            Cursor.Update(gameTime, CameraOperator, World);
            Entities.Update(gameTime, CameraOperator, World);
            Terrain.Update(gameTime, CameraOperator);
            CameraOperator.Update(gameTime, Entities, Factor);
            HUD.Update(gameTime);

            if (Factor < -.1f && _colorFactor == 0)
            {
                Wait.Until(time =>
                {
                    _colorFactor = time.Alive;
                    return(_colorFactor >= 1);
                },
                           () =>
                {
                    InfiniteIsland.GameState = new HighScore(Game, Coins);
                    InfiniteIsland.GameState.LoadContent();
                });
                MediaPlayer.Stop();
            }
        }
Exemplo n.º 7
0
        protected override void Update(GameTime gameTime)
        {
            // Steam Update
            Steam_Manager.Update();

            currentBackground.Update(gameTime);

            //Update input
            Input.Update(gameTime);

            switch (gameState)
            {
            case GameState.Menu:
                menu.Update(gameTime);

                break;

            case GameState.Game:

                thisIsOurGame.Update(gameTime);

                break;
            }


            base.Update(gameTime);
        }
Exemplo n.º 8
0
        public virtual void Update()
        {
            bg.Update();


            for (int i = 0; i < projectiles.Count; i++)
            {
                projectiles[i].Update(offset, mobs);
                if (projectiles[i].done)
                {
                    projectiles.RemoveAt(i);
                    i--;
                }
            }
            for (int i = 0; i < mobs.Count; i++)
            {
                mobs[i].Update();
                if (mobs[i].health <= 0)
                {
                    Globals.score += 1;
                    mobs.RemoveAt(i);
                    i--;
                }
            }
            player.Update();
        }
Exemplo n.º 9
0
        protected override void OnStyleChanged(UIStyle style)
        {
            base.OnStyleChanged(style);

            Background.Update(PeerBackground, DefaultBackground);

            UpdateIcon(Icon);
        }
Exemplo n.º 10
0
        public override void Update(GameTime gameTime)
        {
            TitleFlashSpeedR += 1.0f / gameTime.ElapsedGameTime.Milliseconds * 0.5f;

            Title.SpriteColor = Color.Lerp(Color.Red, Color.Yellow, (float)Math.Sin(TitleFlashSpeedR));

            Background.Update(gameTime);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Updates the background sprite.
        /// </summary>
        /// <param name="gameTime"></param>
        public static void Update(GameTime gameTime)
        {
            if (!PermittedToFadeIn && Background.Animations.Count > 0)
            {
                Background.BrightnessSprite.Animations.Clear();
            }

            Background.Update(gameTime);
        }
Exemplo n.º 12
0
        public void updatesInstructions(GameTime gameTime, ref bool isInstructionsPressed)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                isInstructionsPressed = false;
            }


            gameBackground.Update(gameTime);
        }
Exemplo n.º 13
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            KeyboardState pauseButton = Keyboard.GetState();

            if (pauseButton.IsKeyDown(Keys.P))
            {
                _pauseGame = false;
            }
            CheckLivingEntityCollision(_player);
            if (!_pauseGame)
            {
                if (gc.CurrentLevel == 1 && gc.LevelFinished)
                {
                    gc.LevelFinished = false;
                    gc.CurrentLevel  = 2;
                    _board           = new Board(_spriteBatch, _tileTexture, 59, 25);
                    _board.CreateNewBossBoard();

                    _player.Position = new Vector2(50, ScreenHeight - (TileHeight * 2));
                    _geryon.Position = new Vector2(ScreenWidth - (TileWidth * 2), ScreenHeight - (TileHeight * 2));
                }

                base.Update(gameTime);
                background1.Update(gameTime);
                _player.Update(gameTime);
                _vortex.Update(gameTime, _player);

                _spawn += (float)gameTime.ElapsedGameTime.TotalSeconds;
                foreach (Enemy demon in _demonHorde)
                {
                    demon.Update(gameTime, _player);
                }
                if (gc.CurrentLevel == 1)
                {
                    LoadEnemies();
                }

                for (int i = 0; i < gc.MaxScoreCount; i++)
                {
                    _coins[i].Update(gameTime, _player);
                }
                if (gc.CurrentLevel == 2)
                {
                    _geryon.Update(gameTime, _player);
                    _healthRectangle = new Rectangle(ScreenWidth / 2, ScreenHeight / 10, _geryon.Health, 20);
                    CheckWinCondition();
                }
            }
        }
Exemplo n.º 14
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            MenuBar.Update(gameTime);
            Background.Update(gameTime);

            var screen = (EditorScreen)Screen;

            screen.Ruleset.Update(gameTime);

            Container?.Update(gameTime);
            screen.LayerCompositor?.Update(gameTime);
        }
Exemplo n.º 15
0
        public void Update(ref GameTime gameTime)
        {
            // Updates all creatures, if health is less than 0, they die. Removed from the creature less
            for (int i = Creatures.Count - 1; i >= 0; --i)
            {
                Creatures[i].Update(ref gameTime);
                if (Creatures[i].CurrentHealth <= 0)
                {
                    Creatures[i] = null;
                    Creatures.RemoveAt(i);
                }
            }

            // Updates all the items dropped on the ground
            for (int i = DroppedItems.Count - 1; i >= 0; --i)
            {
                DroppedItems[i].Update(ref gameTime);
                if (DroppedItems[i].LifeTime >= 300) // Removed after 5 mins
                {
                    DroppedItems[i] = null;
                    DroppedItems.RemoveAt(i);
                }
            }

            // Updates all the projectiles, if lifetime is less than or equal to 0, they are removed.
            for (int i = Projectiles.Count - 1; i >= 0; --i)
            {
                Projectiles[i].Update(ref gameTime);
                if (Projectiles[i].LifeTime <= 0)
                {
                    Projectiles[i] = null;
                    Projectiles.RemoveAt(i);
                }
            }

            // If the boss of the level is up then they are updates, when dead a text appears to press N to continue.
            Background.Update(gameTime);
            if (Boss.IsAlive)
            {
                Boss.Update(gameTime);
            }
            else
            {
                TradingManager.Update(gameTime);
                if (Game1.InputManager.KeyClicked(Microsoft.Xna.Framework.Input.Keys.N))
                {
                    Game1.WindowManager.GetGameplayWindow().NewLevel(NextLevel);
                }
            }
        }
Exemplo n.º 16
0
        private void BackgroundUpdate(object state)
        {
            if (IsPaused)
            {
                return;
            }
            var deceased = new List <Element>();

            // update the map
            Background.Update();

            // apply any necessary damage to the players
            for (int i = 0; i < Players.Length; i++)
            {
                if (Players[i] == null || Players[i].IsDead)
                {
                    continue;
                }

                var damage = Background.Damage(Players[i].X, Players[i].Y);
                if (damage > 0)
                {
                    Players[i].ReduceHealth(damage);

                    if (Players[i].IsDead)
                    {
                        deceased.Add(Players[i]);
                    }
                }
            }

            // notify the deceased
            foreach (var elem in deceased)
            {
                // this player has died as a result of taking damage from the zone
                if (OnElementDied != null)
                {
                    OnElementDied(elem);
                }

                if (OnEphemerialEvent != null)
                {
                    OnEphemerialEvent(new Message()
                    {
                        Text = string.Format("Player {0} died in the zone", elem.Name)
                    });
                }
            }
        }
Exemplo n.º 17
0
        public override void Update(GameTime gameTime)
        {
            //Console.WriteLine("Menu State");
            gameBackground.Update(gameTime);
            foreach (var component in components)
            {
                component.Update(gameTime);
            }

            //if instructions button is pressed then update
            if (isInstructionsPressed)
            {
                gamemenuoptions.updatesInstructions(gameTime, ref isInstructionsPressed);
            }
        }
Exemplo n.º 18
0
        public static void UpdateVisual()
        {
            var cameraRect = GetPlayers()[0].GetCollRectangle();

            TMBAW_Game.Camera.UpdateSmoothly(cameraRect, WorldData.LevelWidth, WorldData.LevelHeight, !GetPlayers()[0].IsPlayingDeathAnimation);

            //if (TMBAW_Game.TimeFreeze.IsTimeFrozen())
            //    ParticleSystem.UpdateStartEvent_TimeConstant.Set();
            //ParticleSystem.UpdateTimeConstant();

            DialogueSystem.Update();

            Background.Update();
            WorldData.Update();
        }
Exemplo n.º 19
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
                String     path = "./../../../../Scores.txt";
                TextWriter tw   = new StreamWriter(path, true);
                tw.WriteLine("Player 1: " + scoreByBomberman["Player One"] + "/ Player 2: " + scoreByBomberman["Player Two"]);
                tw.Close();
            }

            for (int i = 0; i < bombermans.Count; i++)
            {
                bombermans[i].Update(gameTime);
                if (background.fireIntersectSomething(bombermans[i].getCurrentPosition()))
                {
                    if (bombermans[i] is BombermanPlayerOne)
                    {
                        this.scoreByBomberman["Player Two"] += 1;
                    }
                    else
                    {
                        this.scoreByBomberman["Player One"] += 1;
                    }
                    background = Background.getInstance(true);
                    enemy      = null;
                    bombermans.Clear();
                    bombermans.Add(BombermanPlayerOne.getInstance(true));
                    bombermans.Add(BombermanPlayerTwo.getInstance(true));
                    lastDieTime = gameTime.TotalGameTime;
                }
            }
            if (enemy == null)
            {
                if (gameTime.TotalGameTime.Subtract(lastDieTime).Seconds > 30)
                {
                    enemy = Enemy.getInstance(true);
                }
            }
            else
            {
                enemy.Update(gameTime);
            }

            background.Update(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 20
0
    public void UpdateAnimations()
    {
        //if is resetting, then do reset animations
        if (currResetFrameNum != -1)
        {
            currResetFrameNum--;

            int numMovingResetFrames = numResetFrames - 3;

            if (currResetFrameNum == numMovingResetFrames - 1)
            {
                SoundManager.PlayBadSound();
            }

            if (currResetFrameNum < numMovingResetFrames)
            {
                DeleteRowsFromBottom((int)Math.Ceiling((double)numSquaresY / (numMovingResetFrames)));
            }
        }
        //else check for row disappearance animatinos
        else
        {
            //update all disappearing rows
            for (int y = disappearingRowsAnimationCtr.Length - 1; y >= 0;)
            {
                if (disappearingRowsAnimationCtr[y] != -1)
                {
                    disappearingRowsAnimationCtr[y]--;

                    if (disappearingRowsAnimationCtr[y] == -1)
                    {
                        DeleteRow(y);
                        // continue without decrementing y
                        // because rows above y is now shifted
                        // down 1 row after deletion.
                        continue;
                    }
                    else
                    {
                        SetRowColor(Square.disappearingColor[disappearingRowsAnimationCtr[y]], y);
                    }
                }
                --y;
            }
        }

        backgroundImage.Update();
    }
Exemplo n.º 21
0
        public void Update()
        {
            b1.Update(0, -1);
            b2.Update(0, -1);

            foreach (var entity in entities)
            {
                //need to change so bullets delete from top too
                if (entity is Bullet || entity is Enemy)
                {
                    if (entity.Location.Y > 500)
                    {
                        RemoveFromDrawList(entity);
                    }
                    if (entity.Location.X > 785 || entity.Location.X < -100)
                    {
                        RemoveFromDrawList(entity);
                    }

                    /*
                     * if (entity is Bullet)
                     * {
                     *  if (entity.Location.Y < 0)
                     *  {
                     *      RemoveFromDrawList(entity);
                     *  }
                     * } */
                }


                updateEntity(entity);
            }

            while (enqueuBuf.First != null)
            {
                updateEntity(enqueuBuf.First.Value);
                entities.AddLast(enqueuBuf.First.Value);
                enqueuBuf.RemoveFirst();
            }

            while (dequeuBuf.First != null)
            {
                entities.Remove(dequeuBuf.First.Value);
                dequeuBuf.RemoveFirst();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Update het speel scherm
        /// </summary>
        /// <param name="gameTime">GameTime object dat ervoor zorgt dat we iets op een bepaalde tijd kunnen afspelen</param>
        /// <param name="camera">Camera2D object dat de hero volgt</param>
        /// <param name="hero">Hero object dat we besturen</param>
        /// <param name="collisionObjects">Lijst met alle objecten die kunnen colliden</param>
        /// <param name="background">Background object voor de game</param>
        /// <param name="collider">Collider object die kijkt of er een collision gebeurt</param>
        /// <param name="currentLevel">Level object dat ons huidig level bevat</param>
        public void Update(GameTime gameTime, Camera2D camera, Hero hero, List <ICollide> collisionObjects, Background background, Collider collider, ref Level currentLevel)
        {
            MediaPlayer.Resume();
            KeyboardState keyboardState = Keyboard.GetState();

            screenManager.MakeMouseVisible(false);
            foreach (ButtonNextLevel nextLevelButton in collisionObjects.OfType <ButtonNextLevel>())
            {
                if (hero.CollisionRectangle.Intersects(nextLevelButton.CollisionRectangle) && hero.Velocity.Y > 5)
                {
                    loadNextLevel = true;
                }
            }
            if (keyboardState.IsKeyDown(Keys.Escape) && escapeReleased)
            {
                escapeReleased = false;
                MediaPlayer.Pause();
                screenManager.SetState(screenManager.GetPauseScreen());
            }
            if (keyboardState.IsKeyUp(Keys.Escape))
            {
                escapeReleased = true;
            }
            camera.Follow(hero);
            background.Update(hero.Position.X);
            hero.Update(gameTime, collisionObjects, collider);
            currentLevel.Update(gameTime, collisionObjects, collider);
            if (hero.AmountOfLives < 0 && hero.currentAnimation.CurrentFrame == hero.deathAnimation.frames[hero.deathAnimation.frames.Count - 1])
            {
                screenManager.SetState(screenManager.GetGameOverScreen());
            }
            if (loadNextLevel)
            {
                MediaPlayer.Pause();
                loadNextLevel = false;
                if (currentLevel is Level1)
                {
                    screenManager.SetState(screenManager.GetNextLevel1Screen());
                }
                else
                {
                    screenManager.SetState(screenManager.GetNextLevel2Screen());
                }
            }
        }
Exemplo n.º 23
0
        public override void Update(GameTime gameTime, Input input)
        {
            if (input.KeyboardStatus.IsKeyJustPressed(Keys.Escape))
            {
                _isPaused = !_isPaused;
            }

            if (!_isPaused && !_isGameOver)
            {
                Background.Update(gameTime);
                World.Update(gameTime, input);
                HUD.Update(gameTime, input);
            }
            else
            {
                PauseMenu.Update(gameTime, input);
            }
        }
Exemplo n.º 24
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 (eventOperator.GameState == EventOperator.GAME_STATE && eventOperator.NewGameState == EventOperator.GAME_STATE)
     {
         UpdateGame(gameTime, false);
         playerUI.Update(gameTime, gameController.Player);
     }
     else
     {
         eventOperator.Update(gameTime);
     }
     Particles.Update(gameTime);
     CheckGameStatus(gameTime);
     InputHandler.UpdatePreviousState();
     Camera.Update(gameTime);
     base.Update(gameTime);
     background.Update(gameTime);
 }
        public void update(GameTime gameTime, SpriteBatch spriteBatch, ref bool isSelectLevelPressed)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                game1Ref.PopInGameMenu_ = true;
            }



            if (!game1Ref.PopInGameMenu_)
            {
                if (LVLClicked)
                {
                    game1Ref.gameManager_.Update(gameTime, spriteBatch);
                    //also reset game status just in case
                    //game1Ref.gameManager_.resetGame();
                }
                else
                {
                    spriteBatch.Begin();
                    gameBackground.Update(gameTime);

                    foreach (var component in components)
                    {
                        component.Draw(gameTime, spriteBatch);
                        component.Update(gameTime);
                    }

                    spriteBatch.End();
                }
            }
            else
            {
                inGameMenu_.Update(gameTime, spriteBatch);
            }

            if (game1Ref.QuitToMain_)
            {
                Console.WriteLine("quitting");
                LVLClicked           = false;
                isSelectLevelPressed = false;
            }
        }
Exemplo n.º 26
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 (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            // TODO: Add your update logic here

            if (Player.isActive)
            {
                player.Update(gameTime);
                floor.Update(gameTime);
                blocks.Update(gameTime);
                collisions.TestCollisions(blocks);
                background.Update(gameTime);

                goblinList.Update(gameTime);
            }
            scoreboard.Update(gameTime);
            base.Update(gameTime);
        }
Exemplo n.º 27
0
        public override void Update(GameTime gameTime, SpriteBatch spriteBatch)
        {
            //Console.WriteLine("Menu State");
            gameBackground.Update(gameTime);

            //if instructions button is pressed then update
            if (isInstructionsPressed)
            {
                gamemenuoptions.updatesInstructions(gameTime, ref isInstructionsPressed);
            }
            else if (isSelectLevelPressed)//if select Level button is pressed then update
            {
                levelSelector.update(gameTime, spriteBatch, ref isSelectLevelPressed);
            }
            else
            {
                foreach (var component in components)
                {
                    component.Update(gameTime);
                }
            }
        }
Exemplo n.º 28
0
        public void Update(Time Elapsed)
        {
            fpsCounter.Update(Elapsed);
            input.Update(Elapsed);
            musicPlayer.Update(Elapsed);

            background.Update(Elapsed);

            if (currentScreen != null)
            {
                currentScreen.Update(Elapsed);
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
            {
                currentScreen.DeActivate();
                currentScreen = mainScreen;
                currentScreen.Activate();
            }

            Console.Title = "fps: " + fpsCounter.FPS;
        }
Exemplo n.º 29
0
        public void Update(GameTime gameTime)
        {
            KeyboardState = Keyboard.GetState();

            if (_previousKeyboardState == null)
            {
                _previousKeyboardState = KeyboardState;
            }

            if (KeyboardState.IsKeyDown(Keys.Escape) && !_previousKeyboardState.IsKeyDown(Keys.Escape) && MenuActive == true && !SceneIsMenu)
            {
                MenuActive = false;
                Menu.End();
            }
            else if (KeyboardState.IsKeyDown(Keys.Escape) && !_previousKeyboardState.IsKeyDown(Keys.Escape) && MenuActive == false && !SceneIsMenu)
            {
                MenuActive = true;
            }

            if (!MenuActive || SceneIsMenu)
            {
                Camera.X += 4;
                UpdateEntities(gameTime);
            }

            if (MenuActive || SceneIsMenu)
            {
                UpdateMenu();
            }

            UpdatePhysics();
            if (Background != null)
            {
                Background.Update();
            }

            _previousKeyboardState = KeyboardState;
        }
Exemplo n.º 30
0
        public override void Update(GameTime gameTime)
        {
            if (Enabled)
            {
                if (!_initated)
                {
                    Initialize();
                }
                //user input management
                if (_player.getBoundToCheckCollision().X > 200)
                {
                    _stageFinished = true;
                }

                if (_stageFinished)
                {
                    if (_stage != MAX_STAGE - 1)
                    {
                        loadStage();
                    }
                }

                KeyboardState ks = Keyboard.GetState();

                MoveDirection tempDirection = MoveDirection.None;

                if (ks.IsKeyUp(Keys.Right) && oldKey.IsKeyDown(Keys.Right))
                {
                    tempDirection = MoveDirection.Right;
                }
                else if (ks.IsKeyDown(Keys.Right))
                {
                    tempDirection = MoveDirection.RunningRight;
                }

                if (ks.IsKeyUp(Keys.Left) && oldKey.IsKeyDown(Keys.Left))
                {
                    tempDirection = MoveDirection.Left;
                }
                else if (ks.IsKeyDown(Keys.Left))
                {
                    tempDirection = MoveDirection.RunningLeft;
                }

                if (ks.IsKeyDown(Keys.Space))
                {
                    // to shoot
                }

                if (ks.IsKeyUp(Keys.Up) && oldKey.IsKeyDown(Keys.Up))
                {
                    _player.stopJump();
                }
                else if (ks.IsKeyDown(Keys.Up))
                {
                    _player.jump();
                }

                _player.Update(tempDirection, _positionManager.getPosition(tempDirection));

                if (_player.Beinghit)
                {
                    tempDirection = MoveDirection.Down;
                }

                oldKey = ks;

                //Only when stage 1
                if (_stage == 0)
                {
                    generateScrollingEnemy();
                }

                _collisionManager.checkAllCollision();
                _status.Update();
                UpdateList(_enemies);
                UpdateList(_items);
                UpdateList(_bullets);
                scrolling1.Update(-1);
                scrolling2.Update(-1);
                base.Update(gameTime);
            }
        }