Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
#if !DEBUG
            if (!IsActive)
            {
                return;
            }
#endif

            if (_wantsToQuit)
            {
                Exit();
            }

            SteamAPI.RunCallbacks();

            GameTime = gameTime;
            GameUpdateCalled?.Invoke();

            InputSystem.Update();

            _frameRateTimer += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (_frameRateTimer > 1000f)
            {
                FPS             = _totalFrames;
                _totalFrames    = 0;
                _frameRateTimer = 0;
            }

            IsMouseVisible = false;

            Cursor.Update();
            SoundtrackManager.Update();

            MessageBox.Update();
            if (MessageBox.IsActive)
            {
                return;
            }

            TextInputBox.Update();
            if (TextInputBox.IsActive)
            {
                return;
            }

            GameDebug.Update();
            if (GameDebug.IsTyping)
            {
                return;
            }

            PauseMenu.Update();
            OptionsMenu.Update();
            if (OptionsMenu.IsActive)
            {
                return;
            }
            if (PauseMenu.IsActive)
            {
                return;
            }

            Dialog.Update();

            Overlay.Update();
            KeyPopUp.Update();

            Player player = GameWorld.GetPlayers()[0];

            Session.Update();

            //Update the game based on what GameState it is
            switch (CurrentGameState)
            {
            case GameState.MainMenu:
                MainMenu.Update();
                if (GameWorld.TileArray != null && GameWorld.TileArray.Length != 0)
                {
                    goto case GameState.GameWorld;
                }
                break;

            case GameState.LoadingScreen:
                LoadingScreen.Update();

                if (!IsLoadingContent)
                {
                    CurrentGameState = _desiredGameState;
                }
                break;

            case GameState.GameWorld:
                if (IsLoadingContent)
                {
                    return;
                }
                if (GameWorld.IsOnDebug)
                {
                    break;
                }
                GameWorld.TotalUpdateTimer.Start();
                if (!TimeFreeze.IsTimeFrozen())
                {
                    GameWorld.UpdateWorld();
                }
                GameWorld.UpdateVisual();
                GameWorld.TotalUpdateTimer.Measure();


                if (StoryTracker.IsInStoryMode)
                {
                    StoryTracker.Update();
                }
                break;
            }

            base.Update(gameTime);
        }