Пример #1
0
        /// <summary>
        /// Handles drawing of the screen. The ScreenManager already provides a GraphicsDevice.Clear() so
        /// there is often no need to clear the screen. This will only be called while the screen is the
        /// active screen.
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        public override void Draw(TickCount gameTime)
        {
            var spriteBatch = DrawingManager.BeginDrawGUI(false);

            if (spriteBatch == null)
            {
                return;
            }

            // Draw an overlay on top of the old screen
            RenderRectangle.Draw(spriteBatch, _cScreen.GetScreenArea(), _overlayColor);

            // Draw the GUI
            GUIManager.Draw(spriteBatch);

            // Draw some extras
            const int yOff = 150;

            spriteBatch.DrawStringShaded(_txtOutput.Font, "FPS: " + ScreenManager.FPS,
                                         new Vector2(_cScreen.ClientSize.X - 100, yOff), Color.White, Color.Black);
            spriteBatch.DrawStringShaded(_txtOutput.Font,
                                         string.Format("Game Time: {0}:{1:00}", GameDateTime.Now.Hour, GameDateTime.Now.Minute),
                                         new Vector2(_cScreen.ClientSize.X - 150, _txtOutput.Font.GetLineSpacing() + yOff), Color.White, Color.Black);

            DrawingManager.EndDrawGUI();
        }
Пример #2
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            if (DesignMode)
            {
                base.HandleDraw(currentTime);
                return;
            }

            var pe = ParticleEffect;

            if (pe == null)
            {
                return;
            }

            if (pe.IsExpired)
            {
                pe.Reset();
            }

            // Update
            pe.Update(currentTime);

            // Draw the world
            try
            {
                var worldSB = DrawingManager.BeginDrawWorld(Camera);
                if (worldSB != null)
                {
                    DrawWorld(worldSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawWorld();
                }
            }

            // Draw the GUI
            try
            {
                var guiSB = DrawingManager.BeginDrawGUI();
                if (guiSB != null)
                {
                    DrawGUI(guiSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawGUI();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Handles drawing of the screen. The ScreenManager already provides a GraphicsDevice.Clear() so
        /// there is often no need to clear the screen. This will only be called while the screen is the
        /// active screen.
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        public virtual void Draw(TickCount gameTime)
        {
            var spriteBatch = DrawingManager.BeginDrawGUI();

            if (spriteBatch == null)
            {
                return;
            }

            GUIManager.Draw(spriteBatch);
            DrawingManager.EndDrawGUI();
        }
Пример #4
0
        /// <summary>
        /// Handles drawing of the screen. The ScreenManager already provides a GraphicsDevice.Clear() so
        /// there is often no need to clear the screen. This will only be called while the screen is the
        /// active screen.
        /// When you override this method, call <see cref="GameMenuScreenBase.DrawBackground"/> with the
        /// <see cref="ISpriteBatch"/> for the GUI to draw the default menu background.
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        public override void Draw(TickCount gameTime)
        {
            var spriteBatch = DrawingManager.BeginDrawGUI();

            if (spriteBatch == null)
            {
                return;
            }

            DrawBackground(spriteBatch);

            GUIManager.Draw(spriteBatch);
            DrawingManager.EndDrawGUI();
        }
Пример #5
0
        /// <summary>
        /// Handles drawing of the screen. The ScreenManager already provides a GraphicsDevice.Clear() so
        /// there is often no need to clear the screen. This will only be called while the screen is the
        /// active screen.
        /// </summary>
        /// <param name="gameTime">The current game time.</param>
        public override void Draw(TickCount gameTime)
        {
            if (UserChar == null)
            {
                return;
            }

            // Update the ambient light based on the game time
            DrawingManager.LightManager.Ambient = Map.GetModifiedAmbientLight();

            // Update the camera
            World.Camera.Min = World.UserChar.GetCameraPos(World.Camera);

            // Since we only update entities in view, and the draw position is included in that update, make sure
            // that the camera focuses on the user properly if they teleport out of view of the camera.
            if (!World.Camera.InView(World.UserChar))
            {
                World.Camera.CenterOn(World.UserChar);
            }

            // Draw the world layer
            try
            {
                var sb = DrawingManager.BeginDrawWorld(World.Camera);
                if (sb == null)
                {
                    return;
                }

                World.Draw(sb);
                _damageTextPool.Draw(sb, _damageFont);
            }
            finally
            {
                DrawingManager.EndDrawWorld();
            }

            // Draw the HUD layer
            try
            {
                var sb = DrawingManager.BeginDrawGUI();
                _infoBox.Draw(sb);
                GUIManager.Draw(sb);
            }
            finally
            {
                DrawingManager.EndDrawGUI();
            }
        }
Пример #6
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            if (DesignMode)
            {
                base.HandleDraw(currentTime);
                return;
            }

            TransBoxManager.Update(currentTime);
            Cursor = TransBoxManager.CurrentCursor;

            int deltaTime;

            if (_lastUpdateTime == TickCount.MinValue)
            {
                deltaTime = 30;
            }
            else
            {
                deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime));
            }

            _lastUpdateTime = currentTime;

            DrawingManager.Update(currentTime);

            _camera.Min += _cameraVelocity * (deltaTime / 1000f);

            // Update
            UpdateMap(currentTime, deltaTime);

            ToolManager.Instance.MapDrawingExtensions.Map = Map;

            // Draw the world
            try
            {
                var worldSB = DrawingManager.BeginDrawWorld(Camera);
                if (worldSB != null)
                {
                    DrawMapWorld(worldSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawWorld();
                }
            }

            // Draw the GUI
            try
            {
                var guiSB = DrawingManager.BeginDrawGUI();
                if (guiSB != null)
                {
                    DrawMapGUI(guiSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawGUI();
                }
            }
        }
Пример #7
0
        /// <summary>
        /// When overridden in the derived class, draws the graphics to the control.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        protected override void HandleDraw(TickCount currentTime)
        {
            if (DesignMode)
            {
                base.HandleDraw(currentTime);
                return;
            }

            TransBoxManager.Update(currentTime);

            // Update the cursor display for the transformation box. Only change the cursor if we are currently
            // under a transbox, or we have just stopped being under one. If we update it every frame, it screws with the
            // UI display for everything else (like when the cursor is over a textbox).
            var transBoxCursor = TransBoxManager.CurrentCursor;

            if (transBoxCursor == null)
            {
                if (_wasUnderTransBox)
                {
                    Cursor            = Cursors.Default;
                    _wasUnderTransBox = false;
                }
            }
            else
            {
                Cursor            = transBoxCursor;
                _wasUnderTransBox = true;
            }

            int deltaTime;

            if (_lastUpdateTime == TickCount.MinValue)
            {
                deltaTime = 30;
            }
            else
            {
                deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime));
            }

            _lastUpdateTime = currentTime;

            DrawingManager.Update(currentTime);

            _camera.Min += _cameraVelocity * (deltaTime / 1000f);

            // Update
            UpdateMap(currentTime, deltaTime);

            ToolManager.Instance.MapDrawingExtensions.Map = Map;

            // Draw the world
            try
            {
                var worldSB = DrawingManager.BeginDrawWorld(Camera);
                if (worldSB != null)
                {
                    DrawMapWorld(worldSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawWorld();
                }
            }

            // Draw the GUI
            try
            {
                var guiSB = DrawingManager.BeginDrawGUI();
                if (guiSB != null)
                {
                    DrawMapGUI(guiSB);
                }
            }
            finally
            {
                if (DrawingManager.State != DrawingManagerState.Idle)
                {
                    DrawingManager.EndDrawGUI();
                }
            }
        }