/// <summary>
        /// Draws the color of the geometry.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="position">The position.</param>
        /// <param name="color">The color.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth)
        {
            XenkoGeometryBuffer xenkoBuffer = buffer as XenkoGeometryBuffer;

            Color4 nativeColor = new Color4(color.PackedValue) * opacity;
            xenkoBuffer.EffectInstance.Parameters.Set(SpriteEffectKeys.Color, nativeColor);
            xenkoBuffer.EffectInstance.Parameters.Set(TexturingKeys.Texture0, GraphicsDevice.GetSharedWhiteTexture());
            DrawGeometry(buffer, position, depth);
        }
Exemple #2
0
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            XnaFont nativeFont = font.GetNativeFont() as XnaFont;

            if (nativeFont != null)
            {
                spriteBatch.DrawStringEx(nativeFont,
                                         text,
                                         new Vector2(position.X, position.Y),
                                         new Color(color.R, color.G, color.B, color.A));
            }
        }
        /// <summary>
        /// Draws the specified texture.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="source">The source.</param>
        /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
        public override void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin)
        {
            testRectangle.X = (int)position.X;
            testRectangle.Y = (int)position.Y;
            testRectangle.Width = (int)renderSize.Width;
            testRectangle.Height = (int)renderSize.Height;
            if (isClipped && !currentScissorRectangle.Intersects(testRectangle))
            {
                return;
            }

            sourceRect.X = (int)source.X;
            sourceRect.Y = (int)source.Y;
            sourceRect.Width = (int)source.Width;
            sourceRect.Height = (int)source.Height;
            vecColor.A = color.A;
            vecColor.R = color.R;
            vecColor.G = color.G;
            vecColor.B = color.B;
            if (centerOrigin)
            {
                origin.X = testRectangle.Width / 2f;
                origin.Y = testRectangle.Height / 2f;
            }

            Texture2D native = texture.GetNativeTexture() as Texture2D;
            spriteBatch.Draw(native, testRectangle, sourceRect, vecColor, 0, origin);
        }
Exemple #4
0
        /// <summary>
        /// Draws the color of the geometry.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="position">The position.</param>
        /// <param name="color">The color.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth)
        {
            if (basicEffect == null)
            {
                basicEffect = new BasicEffect(GraphicsDevice);
            }

            basicEffect.Alpha = color.A / (float)byte.MaxValue * opacity;
            //color = color * effect.Alpha;
            basicEffect.DiffuseColor = new Vector3(color.R / (float)byte.MaxValue, color.G / (float)byte.MaxValue, color.B / (float)byte.MaxValue);
            basicEffect.TextureEnabled = false;
            basicEffect.VertexColorEnabled = true;

            DrawGeometry(buffer, position, depth);
        }
Exemple #5
0
 /// <summary>
 /// Draws the color of the geometry.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="position">The position.</param>
 /// <param name="color">The color.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="depth">The depth.</param>
 public abstract void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth);
Exemple #6
0
        /// <summary>
        /// Draws the color of the geometry.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="position">The position.</param>
        /// <param name="color">The color.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth)
        {
            if (basicEffect == null)
            {
                basicEffect = new BasicEffect(GraphicsDevice);
            }

            basicEffect.Alpha = color.A / (float)byte.MaxValue * opacity;
            //color = color * effect.Alpha;
            basicEffect.DiffuseColor       = new Vector3(color.R / (float)byte.MaxValue, color.G / (float)byte.MaxValue, color.B / (float)byte.MaxValue);
            basicEffect.TextureEnabled     = false;
            basicEffect.VertexColorEnabled = true;

            DrawGeometry(buffer, position, depth);
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GradientStop"/> class.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <param name="offset">The offset.</param>
 public GradientStop(ColorW color, float offset)
 {
     Color  = color;
     Offset = offset;
 }
Exemple #8
0
        public ColorW GetColorW()
        {
            switch (Position)
            {
            case PlayerSocialPosition.OrdinaryPlayer:
                return(ColorW.ConvertToColorW(Color.Black));

            case PlayerSocialPosition.King:
                return(ColorW.ConvertToColorW(Color.Goldenrod));

            case PlayerSocialPosition.Queen:
                return(ColorW.ConvertToColorW(Color.Pink));

            case PlayerSocialPosition.MinisterOfWar:
                return(ColorW.ConvertToColorW(Color.DodgerBlue));

            case PlayerSocialPosition.MinisterOfWealth:
                return(ColorW.ConvertToColorW(Color.LightYellow));

            case PlayerSocialPosition.Hierarch:
                return(ColorW.ConvertToColorW(Color.LightGray));

            case PlayerSocialPosition.Guardians_Chief:
                return(ColorW.ConvertToColorW(Color.AliceBlue));

            case PlayerSocialPosition.Clown:
                return(ColorW.ConvertToColorW(Color.IndianRed));

            case PlayerSocialPosition.Thief:
                return(ColorW.ConvertToColorW(Color.Azure));

            case PlayerSocialPosition.Revolutionary:
                return(ColorW.ConvertToColorW(Color.DarkKhaki));

            case PlayerSocialPosition.Magician:
                return(ColorW.ConvertToColorW(Color.HotPink));;

            case PlayerSocialPosition.Idiot:
                break;

            case PlayerSocialPosition.Vulgar:
                break;

            case PlayerSocialPosition.Rogue:
                break;

            case PlayerSocialPosition.Merchant:
                break;

            case PlayerSocialPosition.Dragon:
                return(ColorW.ConvertToColorW(Color.DarkGoldenrod));

            case PlayerSocialPosition.Admin:
                return(ColorW.ConvertToColorW(Color.PaleGoldenrod));

            case PlayerSocialPosition.Owner:
                return(ColorW.ConvertToColorW(Color.PaleVioletRed));

            default:
                return(ColorW.ConvertToColorW(Color.Transparent));
            }
            return(ColorW.ConvertToColorW(Color.Transparent));
        }
Exemple #9
0
 public static string ToString(ColorW colorW)
 {
     return(colorW.PackedValue.ToString("x8"));
 }
 /// <summary>
 /// Draws the color of the geometry.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <param name="position">The position.</param>
 /// <param name="color">The color.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="depth">The depth.</param>
 public abstract void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth);
 /// <summary>
 /// Draws the text.
 /// </summary>
 /// <param name="font">The font.</param>
 /// <param name="text">The text.</param>
 /// <param name="position">The position.</param>
 /// <param name="renderSize">Size of the render.</param>
 /// <param name="color">The color.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="depth">The depth.</param>
 public abstract void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth);
 /// <summary>
 /// Draws the specified texture.
 /// </summary>
 /// <param name="texture">The texture.</param>
 /// <param name="position">The position.</param>
 /// <param name="renderSize">Size of the render.</param>
 /// <param name="color">The color.</param>
 /// <param name="source">The source.</param>
 /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
 public abstract void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin);
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GradientStop"/> class.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <param name="offset">The offset.</param>
 public GradientStop(ColorW color, float offset)
 {
     Color = color;
     Offset = offset;
 }
Exemple #14
0
 /// <summary>
 /// Draws the text.
 /// </summary>
 /// <param name="font">The font.</param>
 /// <param name="text">The text.</param>
 /// <param name="position">The position.</param>
 /// <param name="renderSize">Size of the render.</param>
 /// <param name="color">The color.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="depth">The depth.</param>
 public abstract void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth);
Exemple #15
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <param name="text">The text.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            if (isClipped)
            {
                testRectangle.X      = (int)position.X;
                testRectangle.Y      = (int)position.Y;
                testRectangle.Width  = (int)renderSize.Width;
                testRectangle.Height = (int)renderSize.Height;

                if (!spriteBatch.GraphicsDevice.ScissorRectangle.Intersects(testRectangle))
                {
                    return;
                }
            }

            vecPosition.X        = position.X;
            vecPosition.Y        = position.Y;
            vecScale.X           = scale.X;
            vecScale.Y           = scale.Y;
            vecColor.PackedValue = color.PackedValue;
            SpriteFont native = font.GetNativeFont() as SpriteFont;

            spriteBatch.DrawString(native, text, vecPosition, vecColor);
        }
Exemple #16
0
        /// <summary>
        /// Draws the specified texture.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
        public override void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, bool centerOrigin)
        {
            Rectangle testRectangle;

            testRectangle.X      = (int)position.X;
            testRectangle.Y      = (int)position.Y;
            testRectangle.Width  = (int)renderSize.Width;
            testRectangle.Height = (int)renderSize.Height;
            if (isClipped && !this.GraphicsDevice.ScissorRectangle.Intersects(testRectangle))
            {
                return;
            }

            this.Prepare(DrawState.Sprite);
            Color vecColor = new Color();

            vecColor.PackedValue = color.PackedValue;
            Texture2D native = texture.GetNativeTexture() as Texture2D;

            spriteBatch.Draw(native, testRectangle, vecColor);
        }
Exemple #17
0
        /// <summary>
        /// Draws the specified texture.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="source">The source.</param>
        /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
        public override void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin)
        {
            testRectangle.X      = (int)position.X;
            testRectangle.Y      = (int)position.Y;
            testRectangle.Width  = (int)renderSize.Width;
            testRectangle.Height = (int)renderSize.Height;
            if (isClipped && !spriteBatch.GraphicsDevice.ScissorRectangle.Intersects(testRectangle))
            {
                return;
            }

            sourceRect.X         = (int)source.X;
            sourceRect.Y         = (int)source.Y;
            sourceRect.Width     = (int)source.Width;
            sourceRect.Height    = (int)source.Height;
            vecColor.PackedValue = color.PackedValue;
            Texture2D native = texture.GetNativeTexture() as Texture2D;

            spriteBatch.Draw(native, testRectangle, sourceRect, vecColor, 0, Vector2.Zero, SpriteEffects.None, 0);
        }
Exemple #18
0
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            var wcR2Font = (font.GetNativeFont() as IWcR2Font)?.BaseFont;

            if (wcR2Font != null)
            {
                if (wcR2Font is XnaFont)
                {
                    //snap pixels
                    position.X = (float)Math.Round(position.X);
                    position.Y = (float)Math.Round(position.Y);

                    Prepare(DrawState.Sprite);
                    spriteBatch.DrawStringEx((XnaFont)wcR2Font,
                                             text,
                                             new Vector2(position.X, position.Y),
                                             new Vector2(renderSize.Width, renderSize.Height),
                                             new Color(color.R, color.G, color.B, color.A));
                }
                else if (wcR2Font is D2DFont)
                {
                    Prepare(DrawState.D2D);
                    d2dRenderer.DrawString((D2DFont)wcR2Font,
                                           text,
                                           new Vector2(position.X, position.Y),
                                           new Vector2(renderSize.Width, renderSize.Height),
                                           new Color(color.R, color.G, color.B, color.A));
                }
            }
        }
        private static Color GetColor(Brush brush)
        {
            ColorW color = ((SolidColorBrush)brush).Color;

            return(Color.FromArgb(color.A, color.R, color.G, color.B));
        }
Exemple #20
0
        /// <summary>
        /// Draws the specified texture.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="source">The source.</param>
        /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
        public override void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin)
        {
            testRectangle.X      = (int)position.X;
            testRectangle.Y      = (int)position.Y;
            testRectangle.Width  = (int)renderSize.Width;
            testRectangle.Height = (int)renderSize.Height;
            if (isClipped && !currentScissorRectangle.Intersects(testRectangle))
            {
                return;
            }

            sourceRect.X      = (int)source.X;
            sourceRect.Y      = (int)source.Y;
            sourceRect.Width  = (int)source.Width;
            sourceRect.Height = (int)source.Height;
            vecColor.A        = color.A;
            vecColor.R        = color.R;
            vecColor.G        = color.G;
            vecColor.B        = color.B;
            if (centerOrigin)
            {
                origin.X = testRectangle.Width / 2f;
                origin.Y = testRectangle.Height / 2f;
            }

            Texture2D native = texture.GetNativeTexture() as Texture2D;

            spriteBatch.Draw(native, testRectangle, sourceRect, vecColor, 0, origin);
        }
Exemple #21
0
        /// <summary>
        /// Draws the specified texture.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="source">The source.</param>
        /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
        public override void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin)
        {
            testRectangle.X = (int)position.X;
            testRectangle.Y = (int)position.Y;
            testRectangle.Width = (int)renderSize.Width;
            testRectangle.Height = (int)renderSize.Height;
            if (isClipped && !spriteBatch.GraphicsDevice.ScissorRectangle.Intersects(testRectangle))
            {
                return;
            }

            sourceRect.X = (int)source.X;
            sourceRect.Y = (int)source.Y;
            sourceRect.Width = (int)source.Width;
            sourceRect.Height = (int)source.Height;
            vecColor.PackedValue = color.PackedValue;
            Texture2D native = texture.GetNativeTexture() as Texture2D;
            spriteBatch.Draw(native, testRectangle, sourceRect, vecColor, 0, Vector2.Zero, SpriteEffects.None, 0);
        }
Exemple #22
0
        /// <summary>
        /// Draws the color of the geometry.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="position">The position.</param>
        /// <param name="color">The color.</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth)
        {
            XenkoGeometryBuffer xenkoBuffer = buffer as XenkoGeometryBuffer;

            Color4 nativeColor = new Color4(color.PackedValue) * opacity;

            xenkoBuffer.EffectInstance.Parameters.Set(SpriteEffectKeys.Color, nativeColor);
            xenkoBuffer.EffectInstance.Parameters.Set(TexturingKeys.Texture0, GraphicsDevice.GetSharedWhiteTexture());
            DrawGeometry(buffer, position, depth);
        }
Exemple #23
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <param name="text">The text.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            if (isClipped)
            {
                testRectangle.X = (int)position.X;
                testRectangle.Y = (int)position.Y;
                testRectangle.Width = (int)renderSize.Width;
                testRectangle.Height = (int)renderSize.Height;

                if (!spriteBatch.GraphicsDevice.ScissorRectangle.Intersects(testRectangle))
                {
                    return;
                }
            }

            vecPosition.X = position.X;
            vecPosition.Y = position.Y;
            vecScale.X = scale.X;
            vecScale.Y = scale.Y;
            vecColor.PackedValue = color.PackedValue;
            SpriteFont native = font.GetNativeFont() as SpriteFont;
            spriteBatch.DrawString(native, text, vecPosition, vecColor);
        }
Exemple #24
0
 /// <summary>
 /// Draws the specified texture.
 /// </summary>
 /// <param name="texture">The texture.</param>
 /// <param name="position">The position.</param>
 /// <param name="renderSize">Size of the render.</param>
 /// <param name="color">The color.</param>
 /// <param name="source">The source.</param>
 /// <param name="centerOrigin">if set to <c>true</c> [center origin].</param>
 public abstract void Draw(TextureBase texture, PointF position, Size renderSize, ColorW color, Rect source, bool centerOrigin);