Esempio n. 1
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = CutlassEngine.Device;
            SpriteBatch    spriteBatch = CutlassEngine.SpriteBatch;
            SpriteFont     font        = FontManager.GetSpriteFontOrDefault(_TitleFont_Id);

            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null);

            #region Draw Menu Options

            // Draw each menu entry in turn.
            for (int i = 0; i < _MenuEntries.Count; i++)
            {
                MenuEntry menuEntry = _MenuEntries[i];

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

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

            #endregion

            #region Draw Title

            // Make the menu slide into place during transitions, using a
            // power curve to make things look more interesting (this makes
            // the movement slow down as it nears the end).
            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

            // Draw the menu title centered on the screen
            Vector2 titlePosition = new Vector2(ResolutionManager.VirtualWidth / 2, 80);
            Vector2 titleSize     = font.MeasureString(_MenuTitle);
            Color   titleColor    = TitleColor * TransitionAlpha;
            float   titleScale    = 1.25f;

            titlePosition.Y -= transitionOffset * 100;

            //Draw title _Text
            spriteBatch.DrawString(font, _MenuTitle, titlePosition, titleColor, 0,
                                   titleSize / 2, titleScale, SpriteEffects.None, 0);

            #endregion

            spriteBatch.End();
        }