Update() private method

private Update ( ) : void
return void
Beispiel #1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                menuManager.ExitGame)
            {
                this.Exit();
            }

            if (InputManager.IsKeyReleased(Keys.Escape) && InputManager.MouseInBounds)
            {
                if (TileGrid.GameState == GameStates.Playing)
                {
                    menuManager.QuitGame();
                    TileGrid.GameState = GameStates.QuitGame;
                }
                else if (TileGrid.GameState == GameStates.QuitGame)
                {
                    TileGrid.GameState = GameStates.Playing;
                }
            }

            InputManager.Update(gameTime);
            resolutionManager.Update(gameTime);

            switch (TileGrid.GameState)
            {
            case GameStates.Menu:
                menuManager.Update(gameTime);
                break;

            case GameStates.Lobby:
                networkingManager.Update(gameTime);
                menuManager.Update(gameTime);
                break;

            case GameStates.StartNewGame:
                tileManager.OnPlayGame(true);
                networkingManager.Update(gameTime);
                tileManager.NewGame();
                break;

            case GameStates.QuitGame:
                menuManager.Update(gameTime);
                networkingManager.Update(gameTime);
                break;

            case GameStates.Playing:
                cameraManager.Update(gameTime);
                tileManager.Update(gameTime);
                networkingManager.Update(gameTime);
                animationManager.Update(gameTime);
                break;
            }
            screenshotManager.Update(gameTime);
            bannerManager.Update(gameTime);
            fpsMonitor.Update(gameTime);
            base.Update(gameTime);
        }
        /// <summary>
        /// Called every frame
        /// </summary>
        /// <param name="gameTime">Snapshot of timing values</param>
        public override void Update(GameTime gameTime)
        {
            networkingManager.Update();

            if (!Paused)
            {
                base.Update(gameTime);
                //TODO: Deprecate
                for (int chunkID = 0; chunkID < chunks.Count; chunkID++)
                {
                    chunks[chunkHashes[chunkID]].Update();
                }
                timer += gameTime.ElapsedGameTime.TotalSeconds;
                float updateTime = 1f / 20;

                while (timer >= updateTime)
                {
                    Tick();
                    timer -= updateTime;
                }
            }
        }