Update() private method

private Update ( ) : void
return void
コード例 #1
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)
            {
                Exit();
            }

            if (ReadyToPlay)
            {
                ReadyToPlay = false;
                state       = State.FleetMenu;
            }
            switch (state)
            {
            case State.MainMenu:
                mainMenu.Update(gameTime);
                break;

            case State.OptionsMenu:
                settingsMenu.Update(gameTime);
                break;

            case State.LoginMenu:
                loginMenu.Update(gameTime);
                break;

            case State.RegisterMenu:
                registerMenu.Update(gameTime);
                break;

            case State.DeckMenu:
                deckMenu.Update(gameTime);
                break;

            case State.GameWindow:
                gameWindow.Update(gameTime);
                break;

            case State.ShopMenu:
                shopMenu.Update(gameTime);
                break;

            case State.FleetMenu:
                fleetMenu.Update(gameTime);
                break;

            case State.CardsMenu:
                cardsMenu.Update(gameTime);
                break;
            }

            base.Update(gameTime);
        }
コード例 #2
0
        /// <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();
            }
            if (menu.getIsButtonPlayPressed())
            {
                menuLogic.setActiveComponent(2);
                menu.setIsButtonPlayPressed(false);
            }
            else if (game.getIsButtonPressed())
            {
                menuLogic.setActiveComponent(1);
                game.setIsButtonPressed(false);
            }
            else if (menu.getIsButtonSettingsPressed())
            {
                menuLogic.setActiveComponent(3);
                menu.setIsButtonSettingsPressed(false);
            }
            else if (settings.getIsButtonBackPressed())
            {
                menuLogic.setActiveComponent(1);
                settings.setIsButtonBackPressed(false);
            }

            if (menuLogic.getActiveComponent() == 1)
            {
                menu.Update(gameTime);
            }
            else if (menuLogic.getActiveComponent() == 2)
            {
                game.Update(gameTime);
            }
            else if (menuLogic.getActiveComponent() == 3)
            {
                settings.Update(gameTime);
            }



            base.Update(gameTime);
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: Bjurbom/itgspelprojekt
        /// <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();
            }

            if (gamestate == Gamestate.exit)
            {
                Exit();
            }
            else if (gamestate == Gamestate.meny)
            {
                meny.update(gameTime);
            }
            else if (gamestate == Gamestate.settings)
            {
                Settings settings = settingsMenu.Update(Keyboard.GetState(), Mouse.GetState());
                debugMode = settings.debugActive;
                if (graphics.PreferredBackBufferWidth != settings.resolution[0] | graphics.PreferredBackBufferWidth != settings.resolution[1])
                {
                    graphics.PreferredBackBufferWidth  = settings.resolution[0];
                    graphics.PreferredBackBufferHeight = settings.resolution[1];
                    graphics.ApplyChanges();
                }
                if (settings.goBack)
                {
                    gamestate = Gamestate.meny;
                }
            }

            // in game
            else if (gamestate == Gamestate.ingame)
            {
                //gör mussen synlig
                IsMouseVisible = true;

                player.PlayerUpdate();
                player.Update();
                //         CameraControls(); //camera controls

                foreach (Creature creature in creatures.creatures)
                {
                    creature.Update();
                    if (creature.canDoBattle && creature.Hitbox.Intersects(player.Hitbox))
                    {
                        battleOpponent = creature;
                        normalBattle   = new NormalBattle(battle, menuBattle, healthMenuBattle, mainBattleMenu, UIList, player, nameInBattle, spriteBatch);
                        gamestate      = Gamestate.battle;
                    }
                }

                // återställer kamran
                // CameraReset();

                //hitdetection
                foreach (CollisionTiles item in map.CollisionTiles)
                {
                    player.PlayerHitdetection(item, camera);

                    camera.Update(player.position);
                }
            }

            //battle
            else if (gamestate == Gamestate.battle)
            {
                normalBattle.Update(camera, gameTime);
            }


            base.Update(gameTime);
        }
コード例 #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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (ReadyToPlay)
            {
                ReadyToPlay = false;
                state       = State.FleetMenu;
            }
            switch (state)
            {
            case State.MainMenu:
                mainMenu.Update(gameTime);
                break;

            case State.OptionsMenu:
                settingsMenu.Update(gameTime);
                break;

            case State.LoginMenu:
                loginMenu.Update(gameTime);
                break;

            case State.RegisterMenu:
                registerMenu.Update(gameTime);
                break;

            case State.DeckMenu:
                deckMenu.Update(gameTime);
                break;

            case State.GameWindow:
                gameWindow.Update(gameTime);
                break;

            case State.ShopMenu:
                shopMenu.Update(gameTime);
                break;

            case State.FleetMenu:
                fleetMenu.Update(gameTime);
                break;

            case State.CardsMenu:
                cardsMenu.Update(gameTime);
                break;
            }

            var toRemove = new List <Animation>();

            animations.ForEach(p =>
            {
                if (p.Update())
                {
                    toRemove.Add(p);
                }
            });
            toRemove.ForEach(p => animations.Remove(p));
            base.Update(gameTime);
        }