Пример #1
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            lineBatch.Begin();

            // draw all actors
            foreach (Actor actor in World.Actors)
            {
                if (actor.Dead == false)
                {
                    actor.Draw(elapsedTime, lineBatch);
                }
            }

            lineBatch.End();

            DrawHud(elapsedTime);

#if ANDROID || IOS
            GamePad.Draw(gameTime, spriteBatch);
#endif
            // draw the stars
            spriteBatch.Begin();
            World.Starfield.Draw(spriteBatch, starTexture);
            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
Пример #2
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            lineBatch.Begin();

            // draw all actors
            foreach (Actor actor in world.Actors)
            {
                if (actor.Dead == false)
                {
                    actor.Draw(elapsedTime, lineBatch);
                }
            }

            // draw all particle systems
            foreach (ParticleSystem particleSystem in world.ParticleSystems)
            {
                if (particleSystem.IsActive)
                {
                    particleSystem.Draw(lineBatch);
                }
            }

            // draw the walls
            world.DrawWalls(lineBatch);

            lineBatch.End();

            // draw the stars
            spriteBatch.Begin();
            world.Starfield.Draw(spriteBatch, starTexture);
            spriteBatch.End();

            if (WorldRules.NeonEffect)
            {
                bloomComponent.Draw(gameTime);
            }

            DrawHud(elapsedTime);

#if ANDROID || IOS || WINDOWS_PHONE
            GamePad.Draw(gameTime, spriteBatch);
#endif

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Darken down any other screens that were drawn beneath the popup.
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            // Center the message text in the viewport.
            Viewport viewport          = ScreenManager.GraphicsDevice.Viewport;
            Vector2  viewportSize      = new Vector2(viewport.Width, viewport.Height);
            Vector2  textSize          = ScreenManager.Font.MeasureString(message);
            Vector2  textPosition      = (viewportSize - textSize) / 2;
            Vector2  usageTextSize     = smallFont.MeasureString(usageText);
            Vector2  usageTextPosition = (viewportSize - usageTextSize) / 2;

            usageTextPosition.Y = textPosition.Y +
                                  ScreenManager.Font.LineSpacing * 2.2f;

            // Draw the background rectangles
            Rectangle rect = new Rectangle(
                (int)(Math.Min(usageTextPosition.X, textPosition.X)),
                (int)(textPosition.Y),
                (int)(Math.Max(usageTextSize.X, textSize.X)),
                (int)(ScreenManager.Font.LineSpacing * 2.2f + usageTextSize.Y)
                );

            rect.X      -= (int)(0.1f * rect.Width);
            rect.Y      -= (int)(0.1f * rect.Height);
            rect.Width  += (int)(0.2f * rect.Width);
            rect.Height += (int)(0.2f * rect.Height);

            Rectangle rect2 = new Rectangle(rect.X - 1, rect.Y - 1,
                                            rect.Width + 2, rect.Height + 2);

            ScreenManager.DrawRectangle(rect2, new Color(World.SelectedArena.Color.R, World.SelectedArena.Color.G, World.SelectedArena.Color.B,
                                                         (int)(192.0f * (float)TransitionAlpha / 255.0f)));
            ScreenManager.DrawRectangle(rect, new Color(0, 0, 0,
                                                        (int)(232.0f * (float)TransitionAlpha / 255.0f)));

            // Fade the popup alpha during transitions.
            Color color = new Color(255, 255, 255, (int)TransitionAlpha);

            // Draw the message box text.
            ScreenManager.SpriteBatch.Begin();
            ScreenManager.SpriteBatch.DrawString(ScreenManager.Font, message,
                                                 textPosition, color);
            ScreenManager.SpriteBatch.DrawString(smallFont, usageText,
                                                 usageTextPosition, color);
            ScreenManager.SpriteBatch.End();
        }
Пример #4
0
        /// <summary>
        /// Draws the pause menu screen. This darkens down the gameplay screen
        /// that is underneath us, and then chains to the base MenuScreen.Draw.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            Viewport viewport     = ScreenManager.GraphicsDevice.Viewport;
            Vector2  viewportSize = new Vector2(viewport.Width, viewport.Height);

            // title
            Vector2 titlePosition = new Vector2(
                (viewportSize.X - titleTexture.Width) / 2f,
                viewportSize.Y * 0.18f);

            titlePosition.Y -= (float)Math.Pow(TransitionPosition, 2) * titlePosition.Y;
            Color titleColor = Color.White;

            ScreenManager.SpriteBatch.Begin();
            ScreenManager.SpriteBatch.Draw(titleTexture, titlePosition,
                                           new Color(titleColor.R, titleColor.G, titleColor.B, TransitionAlpha));
            ScreenManager.SpriteBatch.End();

            base.Draw(gameTime);
        }
Пример #5
0
        /// <summary>
        /// Draws the game-over screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Darken down any other screens that were drawn beneath the popup.
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            Viewport viewport     = ScreenManager.GraphicsDevice.Viewport;
            Vector2  viewportSize = new Vector2(viewport.Width, viewport.Height);

            // calculate the texture position
            Vector2 titlePosition = new Vector2(
                (viewportSize.X - titleTexture.Width) / 2f,
                viewportSize.Y * 0.18f);

            titlePosition.Y -= (float)Math.Pow(TransitionPosition, 2) * titlePosition.Y;
            Color titleColor = Color.White;

            // calculate the message position and size
            float textScale = 1.5f + 0.05f *
                              (float)Math.Cos(gameTime.TotalRealTime.TotalSeconds * 8.0f);
            Vector2 textSize     = ScreenManager.Font.MeasureString(message);
            Vector2 textPosition = new Vector2(
                viewportSize.X / 2f - textSize.X / 2f * textScale,
                viewportSize.Y * 0.417f);

            titlePosition.Y -= (float)Math.Pow(TransitionPosition, 2) * titlePosition.Y;
            textSize.X       = 0f;
            textSize.Y      /= 2f;

            // draw the texture and text
            ScreenManager.SpriteBatch.Begin();
            ScreenManager.SpriteBatch.Draw(titleTexture, titlePosition,
                                           new Color(titleColor.R, titleColor.G, titleColor.B, TransitionAlpha));
            ScreenManager.SpriteBatch.DrawString(ScreenManager.Font, message,
                                                 textPosition, new Color(0, 255, 0, TransitionAlpha), 0.0f, textSize,
                                                 textScale, SpriteEffects.None, 1.0f);
            ScreenManager.SpriteBatch.End();

            base.Draw(gameTime);
        }