示例#1
0
        /// <summary>
        /// Renders this screen.
        /// </summary>
        /// <param name="time">The GameTime object from the XNA framework.</param>
        /// <param name="batch">The spritebatch on which to render the screen.</param>
        public virtual void Draw(GameTime time, SpriteBatch batch)
        {
            // Break early if user made menu invisible
            if (!Visible)
            {
                return;
            }

            // Check if this menu is hidden behind other screens
            if (_VisiblyObscured && !_VisibleWhenObscured && !_Fading)
            {
                return;
            }

            // Begin screen drawing


            // Draw each of the screen's entities
            _Entities.ForEach(DrawEntity, time, batch, null);

            // Draw the message string
            if (_Message != null && _MessageFont != null)
            {
                Vector2 TopLeft_Pixels = ViewPort.Transform_UnitPosition_To_PixelPosition(MessageLocation);
                Vector2 Size_Pixels    = ViewPort.Transform_UnitSize_To_PixelSize(MessageFont.MeasureString(Message));
                Vector2 Scale          = Size_Pixels / MessageFont.MeasureString(Message);

                batch.DrawString(_MessageFont, _Message, TopLeft_Pixels, _MessageColour, 0.0f, new Vector2(0, 0), Scale.X, SpriteEffects.None, Depth);
            }
        }
示例#2
0
        /// <summary>
        /// Draws the everything on the screen.
        /// </summary>
        /// <param name="time">The XNA game time.</param>
        /// <param name="batch">The spritebatch to draw to.</param>
        public virtual void Draw(GameTime time, SpriteBatch batch)
        {
            // Break early if user made menu invisible
            if (!Visible)
            {
                return;
            }

            // Check if this menu is hidden behind other screens
            if (_VisiblyObscured && !_VisibleWhenObscured && !_Fading)
            {
                return;
            }

            // Draw background tiles
            if (Tiles.Loaded.Count > 0)
            {
                batch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
                _Tiles.Loaded.ForEach(DrawEntity, time, batch, null);
                _Walls.Loaded.ForEach(DrawEntity, time, batch, null);
                batch.End();
            }

            // Draw active entities
            if (Entities.Loaded.Count > 0)
            {
                batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.None);
                _Entities.Loaded.ForEach(DrawEntity, time, batch, null);
                batch.End();
            }

            // Draw blood splatters
            if (Blood.Loaded.Count > 0)
            {
                batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                _Blood.Loaded.ForEach(DrawEntity, time, batch, null);
                batch.End();
            }

            // Draw the message string
            if (_Message != null && _MessageFont != null)
            {
                batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                Vector2 TopLeft_Pixels = new Vector2(20, 20);
                Vector2 Size_Pixels    = MessageFont.MeasureString(Message);

                batch.DrawString(_MessageFont, _Message, TopLeft_Pixels, _MessageColour, 0.0f, new Vector2(0, 0), 1f, SpriteEffects.None, Depth);
                batch.End();
            }
        }