Ejemplo n.º 1
0
        void fx_Update()
        {
            if (fx_on || fx_end)
            {
                Vector2 size     = Game.GetFont("fxFont").MeasureString(fx_text) * fx_scale;
                Vector2 position = new Vector2(
                    Game.GameWidth / 2 - size.X / 2 + 0,
                    Offset.Y);
                Offset += Velocity;

                if (fx_on)
                {
                    Game.SpriteBatch.DrawString(
                        Game.GetFont("fxFont"),
                        fx_text,
                        position,
                        GraphicsHelper.GetColorWithAlpha(ForeColor, fx_alpha), 0,
                        Vector2.Zero, // size / 2,
                        fx_scale,
                        SpriteEffects.None, 0);
                    if (fx_scale > fx_scale_end)
                    {
                        fx_scale += fx_scale_speed;
                    }
                    else
                    {
                        fx_on = false; fx_end = true;
                    }
                    if (fx_alpha < fx_alpha_end)
                    {
                        fx_alpha += fx_alpha_speed;
                    }
                }
                else
                {
                    Game.SpriteBatch.DrawString(
                        Game.GetFont("fxFont"),
                        fx_text,
                        position,
                        GraphicsHelper.GetColorWithAlpha(ForeColor, fx_alpha2), 0,
                        Vector2.Zero,
                        fx_scale,
                        SpriteEffects.None, 0);
                    if (fx_alpha2 > fx_alpha2_end)
                    {
                        fx_alpha2 += fx_alpha2_speed;
                    }
                    else
                    {
                        fx_end = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            Rectangle bounds = new Rectangle((int)(Position.X), (int)(Position.Y), (int)(Size.X), (int)(Size.Y));

            var sprite = Game.GetSlice(BackgroundImage);

            spriteBatch.Draw(sprite.Texture, bounds, sprite.Crop, TintColor); // Draw Background

            Vector2 textsize = Game.GetFont(Font).MeasureString(Caption);

            GraphicsHelper.DrawShadowedString(spriteBatch, Game.GetFont(Font), Caption, Position + new Vector2(Size.X / 2 - textsize.X / 2, Size.Y / 2 - textsize.Y / 2),
                                              (Enabled ?(IsMouseHold ? MouseHoldColor :
                                                         (IsMouseHovered ? MouseHoverColor :
                                                          ForeColor)):DisabledColor),
                                              ShadowColor);
        }
Ejemplo n.º 3
0
        public virtual void Draw(GameTime gameTime)
        {
            var         font     = Game.GetFont(FontName);
            var         solid    = Game.GetTexture("solid");
            var         n        = Messages.First;
            float       y        = Position.Y;
            const float vspacing = 4.0f;
            const float hspacing = 10.0f;
            Effect      crop     = Game.GetEffect("crop");

            while (n != null)
            {
                Vector2 size      = font.MeasureString(n.Value.Text);
                float   rectWidth = (size.X + 2 * hspacing);
                float   coef      = (float)n.Value.Life * 10 / (float)ElegantMessage.TTL;
                rectWidth = Math.Min(rectWidth, rectWidth * coef);
                if (coef < 1.0f && !n.Value.Dead)
                {
                    n.Value.Dead = true;
                    PlayDeathSound();
                }
                Rectangle bounds = new Rectangle(
                    (int)((Align == ElegantMessageAlignModes.Left ? 0 : -size.X) - hspacing + Position.X),
                    (int)(y),
                    (int)(rectWidth),
                    (int)(size.Y + 2.0f * vspacing));

                Game.SpriteBatch.Draw(solid,
                                      bounds, BackColor);
                y += vspacing;

                Game.SpriteBatch.End();
                Game.PushTarget(target);
                Game.GraphicsDevice.Clear(Color.Transparent);
                Game.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
                Game.SpriteBatch.DrawString(font, n.Value.Text,
                                            new Vector2((Align == ElegantMessageAlignModes.Left ? 0 : -size.X) + Position.X,
                                                        y),
                                            ForeColor);
                Game.SpriteBatch.End();
                Game.PopTarget();
                Game.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
                                       null, DepthStencilState.None, RasterizerState.CullNone, crop);
                crop.Parameters["top"].SetValue((float)bounds.Top / (float)Game.GameHeight);
                crop.Parameters["down"].SetValue((float)bounds.Bottom / (float)Game.GameHeight);
                crop.Parameters["left"].SetValue((float)bounds.Left / (float)Game.GameWidth);
                crop.Parameters["right"].SetValue((float)bounds.Right / (float)Game.GameWidth);
                Game.SpriteBatch.Draw(target, Vector2.Zero, ForeColor);

                /*Game.SpriteBatch.DrawString(font, n.Value.Text,
                 *  new Vector2((Align == ElegantMessageAlignModes.Left ? 0 : -size.X) + Position.X,
                 *      y),
                 *  ForeColor);*/
                Game.RestartBatch();
                y += vspacing + size.Y;
                n  = n.Next;
            }
        }
Ejemplo n.º 4
0
        public override void Draw(GameTime gameTime)
        {
            if (alpha > 0)
            {
                game.SpriteBatch.Begin();
                game.SpriteBatch.Draw(game.GetTexture("mediaHUD"),
                                      DrawPosition, GraphicsHelper.GetColorWithAlpha(Color.White, alpha));

                //text
                try
                {
                    GraphicsHelper.DrawShadowedString(game.SpriteBatch,
                                                      game.GetFont(FontName),
                                                      trackName,
                                                      DrawPosition + trackNameOffset,
                                                      GraphicsHelper.GetColorWithAlpha(Color.White, alpha),
                                                      GraphicsHelper.GetColorWithAlpha(Color.Black, alpha));

                    GraphicsHelper.DrawShadowedString(game.SpriteBatch, game.GetFont(FontName),
                                                      trackAlbum,
                                                      DrawPosition + trackAlbumOffset,
                                                      GraphicsHelper.GetColorWithAlpha(Color.White, alpha),
                                                      GraphicsHelper.GetColorWithAlpha(Color.Black, alpha));

                    GraphicsHelper.DrawShadowedString(game.SpriteBatch, game.GetFont(FontName),
                                                      trackArtist,
                                                      DrawPosition + trackArtistOffset,
                                                      GraphicsHelper.GetColorWithAlpha(Color.White, alpha),
                                                      GraphicsHelper.GetColorWithAlpha(Color.Black, alpha));
                }
                catch
                { alpha = 0; }
                game.SpriteBatch.End();
            }
            base.Draw(gameTime);
        }