Esempio n. 1
0
        /// <summary>
        /// Draw
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = ScreenManager.Font;

            spriteBatch.Begin();

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                bool isSelected = IsActive && (i == selectedEntry);

                menuEntry.Draw(this, isSelected, gameTime);
            }

            // Wyliczanie efektu "slide" który wykonują pozycje w menu
            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

            Vector2 titlePosition = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width * 3 / 4, ScreenManager.GraphicsDevice.Viewport.Height * 7 / 16);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
            Color   titleColor    = new Color(0, 0, 193) * TransitionAlpha;
            float   titleScale    = 1.25f;

            titlePosition.Y -= transitionOffset * 100;

            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                   titleOrigin, titleScale, SpriteEffects.None, 0);

            spriteBatch.End();
        }
Esempio n. 2
0
        /// <summary>
        /// Draw
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            Viewport viewport     = ScreenManager.GraphicsDevice.Viewport;
            Vector2  viewportSize = new Vector2(viewport.Width, viewport.Height);
            Vector2  textSize     = font.MeasureString(message);

            textSize.Y += choices[0].GetHeight(ScreenManager.Font);
            Vector2 textPosition = (viewportSize - textSize) / 2;

            const int hPad = 32;
            const int vPad = 16;



            Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad,
                                                          (int)textPosition.Y - vPad,
                                                          (int)textSize.X + hPad * 2,
                                                          (int)textSize.Y + vPad * 2);

            Color color = Color.White * TransitionAlpha;

            spriteBatch.Begin();

            spriteBatch.Draw(gradientTexture, backgroundRectangle, color);
            spriteBatch.DrawString(font, message, textPosition, color);


            // Rysowanie pozycji menu
            Vector2 position = textPosition;

            position.X         += textSize.X / 2 + choices[1].GetWidth(ScreenManager.Font) - hPad;
            position.Y         += textSize.Y / 2 + vPad;
            choices[1].Position = position;
            position.X         -= choices[1].GetWidth(ScreenManager.Font) + 2 * hPad;
            choices[0].Position = position;

            for (int i = 0; i < choices.Count; i++)
            {
                MenuEntry menuEntry = choices[i];

                bool isSelected = IsActive && (i == selected);

                menuEntry.Draw(this, isSelected, gameTime);
            }

            spriteBatch.End();
        }