Exemplo n.º 1
0
        void Mirror_IsSelectedChanged(object sender, EventArgs e)
        {
            if (_mirrorLR.IsSelected && _mirrorTB.IsSelected)
            {
                _charPreview[_charPreview.Width - 2, 0].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically | Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            }
            else if (_mirrorLR.IsSelected)
            {
                _charPreview[_charPreview.Width - 2, 0].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            }
            else if (_mirrorTB.IsSelected)
            {
                _charPreview[_charPreview.Width - 2, 0].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
            }
            else
            {
                _charPreview[_charPreview.Width - 2, 0].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.None;
            }

            _popupCharacterWindow.MirrorEffect = _characterPicker.MirrorEffect = _settingMirrorEffect = _charPreview[_charPreview.Width - 2, 0].Mirror;

            if (!_skipChanged)
            {
                OnChanged();
            }
        }
Exemplo n.º 2
0
 public AnimationFrame(AnimationFrame original)
 {
     this.Used = original.Used;
     this.Effect = original.Effect;
     this.Color = Color.FromNonPremultiplied(original.Color.ToVector4());
     this.Region = new Rectangle(original.Region.X, original.Region.Y, original.Region.Width, original.Region.Height);
     this.Rotation = original.Rotation;
     this.Origin = original.Origin;
     this.Scale = original.Scale;
 }
Exemplo n.º 3
0
        public override void SetSpriteEffects(int i, int j, ref Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffects)
        {
            if ((i + j) % 2 == 0)
            {
                spriteEffects |= Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            }

            if (!TileIsBase(i, j + 1) && TileIsBase(i, j - 1))
            {
                spriteEffects |= Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
            }
        }
        public override void GuardianPostDrawScript(TerraGuardian guardian, Microsoft.Xna.Framework.Vector2 DrawPosition, Microsoft.Xna.Framework.Color color, Microsoft.Xna.Framework.Color armorColor, float Rotation, Microsoft.Xna.Framework.Vector2 Origin, float Scale, Microsoft.Xna.Framework.Graphics.SpriteEffects seffect)
        {
            const float Opacity = 0.8f;

            if (GetIfIsCloudForm(guardian))
            {
                foreach (GuardianDrawData gdd in TerraGuardian.DrawBehind)
                {
                    if (!TerraGuardian.DrawingIgnoringLighting &&
                        gdd.textureType != GuardianDrawData.TextureType.MainHandItem && gdd.textureType != GuardianDrawData.TextureType.OffHandItem &&
                        gdd.textureType != GuardianDrawData.TextureType.Effect && gdd.textureType != GuardianDrawData.TextureType.Wings &&
                        gdd.textureType != GuardianDrawData.TextureType.TGHeadAccessory)
                    {
                        gdd.color *= Opacity;
                    }
                }
                foreach (GuardianDrawData gdd in TerraGuardian.DrawFront)
                {
                    if (!TerraGuardian.DrawingIgnoringLighting &&
                        gdd.textureType != GuardianDrawData.TextureType.MainHandItem && gdd.textureType != GuardianDrawData.TextureType.OffHandItem &&
                        gdd.textureType != GuardianDrawData.TextureType.Effect && gdd.textureType != GuardianDrawData.TextureType.Wings &&
                        gdd.textureType != GuardianDrawData.TextureType.TGHeadAccessory)
                    {
                        gdd.color *= Opacity;
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Sets the sprite effect of a specified cell.
 /// </summary>
 /// <param name="x">The x location of the cell.</param>
 /// <param name="y">The y location of the cell.</param>
 /// <param name="mirror">The mirror of the cell.</param>
 public void SetMirror(int x, int y, SpriteEffects mirror)
 {
     textSurface.Cells[y * textSurface.Width + x].Mirror = mirror;
     textSurface.IsDirty = true;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Changes the glyph, foreground, background, and effect of a cell.
        /// </summary>
        /// <param name="x">The x location of the cell.</param>
        /// <param name="y">The y location of the cell.</param>
        /// <param name="glyph">The desired glyph.</param>
        /// <param name="foreground">The desired foreground.</param>
        /// <param name="background">The desired background.</param>
        /// <param name="effect">Sets the effect of the cell</param>
        public void SetGlyph(int x, int y, int glyph, Color foreground, Color background, SpriteEffects mirror)
        {
            int index = y * textSurface.Width + x;

            textSurface.Cells[index].Background = background;
            textSurface.Cells[index].Foreground = foreground;
            textSurface.Cells[index].Glyph      = glyph;
            textSurface.Cells[index].Mirror     = mirror;

            textSurface.IsDirty = true;
        }
Exemplo n.º 7
0
        public override void ModifyDrawDatas(List <GuardianDrawData> dds, Vector2 Position, Rectangle BodyRect, Rectangle LArmRect, Rectangle RArmRect, Vector2 Origin, Color color, Microsoft.Xna.Framework.Graphics.SpriteEffects seffects)
        {
            Microsoft.Xna.Framework.Graphics.Texture2D BagTexture = Base.sprites.GetExtraTexture(Companions.BreeBase.BagTextureID);
            Rectangle backrect  = BodyRect,
                      frontrect = BodyRect;

            backrect.Y += backrect.Height;
            GuardianDrawData bagback  = new GuardianDrawData(GuardianDrawData.TextureType.TGExtra, BagTexture, Position, backrect, color, npc.rotation, Origin, npc.scale, seffects),
                             bagfront = new GuardianDrawData(GuardianDrawData.TextureType.TGExtra, BagTexture, Position, frontrect, color, npc.rotation, Origin, npc.scale, seffects);

            for (int i = dds.Count - 1; i >= 0; i--)
            {
                if (dds[i].textureType == GuardianDrawData.TextureType.TGBody)
                {
                    dds.Insert(i + 1, bagfront);
                    dds.Insert(i, bagback);
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Sets the sprite effect of a specified cell.
 /// </summary>
 /// <param name="x">The x location of the cell.</param>
 /// <param name="y">The y location of the cell.</param>
 /// <param name="spriteEffect">The sprite effect of the cell.</param>
 public void SetSpriteEffect(int x, int y, SpriteEffects spriteEffect)
 {
     textSurface.Cells[y * textSurface.Width + x].SpriteEffect = spriteEffect;
 }
Exemplo n.º 9
0
        void Mirror_IsSelectedChanged(object sender, EventArgs e)
        {
            if (_mirrorLR.IsSelected && _mirrorTB.IsSelected)
                _charPreview[_charPreview.Width - 2, 0].SpriteEffect = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically | Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            else if (_mirrorLR.IsSelected)
                _charPreview[_charPreview.Width - 2, 0].SpriteEffect = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally;
            else if (_mirrorTB.IsSelected)
                _charPreview[_charPreview.Width - 2, 0].SpriteEffect = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically;
            else
                _charPreview[_charPreview.Width - 2, 0].SpriteEffect = Microsoft.Xna.Framework.Graphics.SpriteEffects.None;

            _popupCharacterWindow.MirrorEffect = _characterPicker.MirrorEffect = _settingMirrorEffect = _charPreview[_charPreview.Width - 2, 0].SpriteEffect;

            if (!_skipChanged)
                OnChanged();
        }
Exemplo n.º 10
0
        public override void  ModifyDrawDatas(List <GuardianDrawData> dds, Vector2 Position, Rectangle BodyRect, Rectangle LArmRect, Rectangle RArmRect, Vector2 Origin, Color color, Microsoft.Xna.Framework.Graphics.SpriteEffects seffects)
        {
            GuardianDrawData dd = new GuardianDrawData(GuardianDrawData.TextureType.TGExtra, Base.sprites.GetExtraTexture("tails"), Position, BodyRect, color, 0f, Origin, 1f, seffects);

            dds.Insert(0, dd);
        }
Exemplo n.º 11
0
 public override void SetSpriteEffects(int i, int j, ref Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffects)
 {
 }
Exemplo n.º 12
0
        private void DrawWing(SceneGame scene, SpriteReference sprite, Color color, int segments, float directionMod, float distanceMod, Microsoft.Xna.Framework.Graphics.SpriteEffects mirror)
        {
            //new Color(244, 211, 23)
            //SpriteReference hand = SpriteLoader.Instance.AddSprite("content/hand");
            int index = 0;

            for (int i = 1; i <= segments; i++)
            {
                int     subSegments = 9;
                float   angle       = directionMod * MathHelper.ToRadians(90 - i * 5);
                float   distance    = (float)LerpHelper.Quadratic(10, distanceMod * 50, (float)i / segments);
                Vector2 pivot       = VisualPosition() + Util.AngleToVector(angle) * distance;
                scene.DrawSpriteExt(sprite, 0, pivot + GetHandOffset(index), sprite.Middle, angle + directionMod * MathHelper.PiOver4, Vector2.One, mirror, color, 0);
                index++;
                for (int e = 0; e <= subSegments; e++)
                {
                    float subSegmentSlide = (float)e / (subSegments + 1);
                    float subAngle        = angle - directionMod * MathHelper.ToRadians(i * 2);
                    float subDistance     = distanceMod * e * 5;
                    float visAngle        = subAngle + directionMod * MathHelper.PiOver2 + directionMod * MathHelper.ToRadians(i * -10);
                    scene.DrawSpriteExt(sprite, 0, pivot + GetHandOffset(index) + Util.AngleToVector(subAngle) * subDistance, sprite.Middle, visAngle, Vector2.One, mirror, color * MathHelper.Lerp(0.3f, 1, subSegmentSlide), 0);
                    index++;
                }
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Sets the sprite effect of a specified cell.
 /// </summary>
 /// <param name="x">The x location of the cell.</param>
 /// <param name="y">The y location of the cell.</param>
 /// <param name="spriteEffect">The sprite effect of the cell.</param>
 public void SetSpriteEffect(int x, int y, SpriteEffects spriteEffect)
 {
     textSurface.Cells[y * textSurface.Width + x].SpriteEffect = spriteEffect;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Draws the string on the console at the specified location with the specified settings. 
        /// </summary>
        /// <param name="x">X location of the text.</param>
        /// <param name="y">Y location of the text.</param>
        /// <param name="text">The string to display.</param>
        /// <param name="foreground">Sets the foreground of all characters in the text.</param>
        /// <param name="background">Sets the background of all characters in the text.</param>
        /// <param name="spriteEffect">The sprite effect to set on the cell.</param>
        public void Print(int x, int y, string text, Color? foreground = null, Color? background = null, SpriteEffects? spriteEffect = null)
        {
            if (String.IsNullOrEmpty(text))
                return;

            if (x >= textSurface.Width || x < 0 || y >= textSurface.Height || y < 0)
                throw new Exception("X,Y is out of range for Print");

            int index = y * textSurface.Width + x;

            if (!UsePrintProcessor)
            {
                int total = index + text.Length > textSurface.Cells.Length ? textSurface.Cells.Length - index : index + text.Length;
                int charIndex = 0;
                for (; index < total; index++)
                {
                    textSurface.Cells[index].GlyphIndex = text[charIndex];

                    if (background.HasValue)
                        textSurface.Cells[index].Background = background.Value;
                    if (foreground.HasValue)
                        textSurface.Cells[index].Foreground = foreground.Value;
                    if (spriteEffect.HasValue)
                        textSurface.Cells[index].SpriteEffect = spriteEffect.Value;

                    charIndex++;
                }
            }
            else
            {
                var stacks = new ParseCommandStacks();

                if (foreground.HasValue)
                    stacks.AddSafe(new ParseCommandRecolor() { R = foreground.Value.R, G = foreground.Value.G, B = foreground.Value.B, A = foreground.Value.A, CommandType = CommandTypes.Foreground });

                if (background.HasValue)
                    stacks.AddSafe(new ParseCommandRecolor() { R = background.Value.R, G = background.Value.G, B = background.Value.B, A = background.Value.A, CommandType = CommandTypes.Background });

                if (spriteEffect.HasValue)
                    stacks.AddSafe(new ParseCommandSpriteEffect() { Effect = spriteEffect.Value, CommandType = CommandTypes.SpriteEffect });

                PrintNoCheck(index, ColoredString.Parse(text, index, textSurface, this, stacks));
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Fills the specified area.
        /// </summary>
        /// <param name="area">The area to fill.</param>
        /// <param name="foreground">Foregorund of every cell. If null, skips.</param>
        /// <param name="background">Foregorund of every cell. If null, skips.</param>
        /// <param name="glyph">Glyph of every cell. If null, skips.</param>
        /// <param name="spriteEffect">Sprite effect of every cell. If null, skips.</param>
        public Cell[] Fill(Rectangle area, Color? foreground, Color? background, int? glyph, SpriteEffects? spriteEffect = null)
        {
            // Check for valid rect
            Rectangle consoleArea = new Rectangle(0, 0, textSurface.Width, textSurface.Height);

            if (consoleArea.Contains(area))
            {
                var cells = new Cell[consoleArea.Width * consoleArea.Height];
                int cellIndex = 0;

                for (int x = area.Left; x < area.Left + area.Width; x++)
                {
                    for (int y = area.Top; y < area.Top + area.Height; y++)
                    {
                        Cell cell = textSurface[y * textSurface.Width + x];

                        if (glyph.HasValue)
                            cell.GlyphIndex = glyph.Value;
                        if (background.HasValue)
                            cell.Background = background.Value;
                        if (foreground.HasValue)
                            cell.Foreground = foreground.Value;
                        if (spriteEffect.HasValue)
                            cell.SpriteEffect = spriteEffect.Value;

                        cells[cellIndex] = cell;
                        cellIndex++;
                    }
                }

                return cells;
            }

            return new Cell[] { };
        }
Exemplo n.º 16
0
        /// <summary>
        /// Fills the console.
        /// </summary>
        /// <param name="foreground">Foregorund of every cell. If null, skips.</param>
        /// <param name="background">Foregorund of every cell. If null, skips.</param>
        /// <param name="glyph">Glyph of every cell. If null, skips.</param>
        /// <param name="spriteEffect">Sprite effect of every cell. If null, skips.</param>
        public Cell[] Fill(Color? foreground, Color? background, int? glyph, SpriteEffects? spriteEffect = null)
        {
            for (int i = 0; i < textSurface.Cells.Length; i++)
            {
                if (glyph.HasValue)
                    textSurface.Cells[i].GlyphIndex = glyph.Value;
                if (background.HasValue)
                    textSurface.Cells[i].Background = background.Value;
                if (foreground.HasValue)
                    textSurface.Cells[i].Foreground = foreground.Value;
                if (spriteEffect.HasValue)
                    textSurface.Cells[i].SpriteEffect = spriteEffect.Value;
            }

            return textSurface.Cells;
        }