Ejemplo n.º 1
0
        /// <summary>
        /// Draws things that are only seen by the camera in the gameworld.
        /// </summary>
        private static void DrawGameWorld()
        {
            int width  = TMBAW_Game.UserResWidth;
            int height = TMBAW_Game.UserResHeight;

            if (TMBAW_Game.CurrentGameState == GameState.LoadingScreen)
            {
                return;
            }

            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DefaultDepthStencil, DefaultRasterizer, null);
            _spriteBatch.Draw(_wallRenderTarget, new Rectangle(0, 0, TMBAW_Game.DefaultResWidth, TMBAW_Game.DefaultResHeight), Color.White);
            _spriteBatch.End();


            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DefaultDepthStencil, DefaultRasterizer, null, TMBAW_Game.Camera.Translate);
            GameWorld.Draw(_spriteBatch);
            ParticleSystem.DrawNormalParticles(_spriteBatch);
            KeyPopUp.Draw(_spriteBatch);
            _spriteBatch.End();
            //GameWorld.DrawRipples(_spriteBatch);

            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DefaultDepthStencil, DefaultRasterizer, null, TMBAW_Game.Camera.Translate);
            GameWorld.DrawGlows(_spriteBatch);
            _spriteBatch.End();


            _spriteBatch.End();
        }
Ejemplo n.º 2
0
 public override void Update(Tile tile)
 {
     foreach (Player player in GameWorld.GetPlayers())
     {
         if (player.GetCollRectangle().Intersects(_collRectangle))
         {
             KeyPopUp.Show("W", player.GetCollRectangle());
             if (player.IsInteractPressed())
             {
                 OnPlayerAction(tile, player);
             }
         }
     }
     base.Update(tile);
 }
Ejemplo n.º 3
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);
        }