Example #1
0
        public override void Render(FrameEventArgs e)
        {
            base.Render(e);
            Texture texture = GetSpriteTexture();

            if (texture != null)
            {
                int textureWidth  = texture.GetWidth() / _xFrames;
                int textureHeight = texture.GetHeight() / _yFrames;
                int textureX      = _currentXFrame * textureWidth;
                int textureY      = _currentYFrame * textureHeight;

                float width  = (float)textureWidth * Transform.Scale.X;
                float height = (float)textureHeight * Transform.Scale.Y;

                Vector3    offset = Vector3.Zero;
                SpriteData data   = SpriteData.GetSpriteData(_spriteID);
                if (GetYFrame() == 0 || GetYFrame() == 3)
                {
                    offset.X = -data.VerticalAnchorPoint.X;
                    offset.Y = -data.VerticalAnchorPoint.Y;
                }
                else
                {
                    offset.X = -data.HorizontalAnchorPoint.X;
                    offset.Y = -data.HorizontalAnchorPoint.Y;
                }


                Vector3   pos    = Transform.Position;
                Vector3   scale  = new Vector3(width, height, 1);
                Vector3   rot    = Transform.Rotation;
                Rectangle source = new Rectangle(textureX, textureY, textureWidth, textureHeight);
                if (!BushFlag())
                {
                    Renderer.FillTexture(texture, ShapeFactory.Rectangle, ref pos, ref scale, ref rot, ref offset, ref source, ref _colour);
                }
                else
                {
                    Color4 color2 = new Color4(1, 1, 1, 0.25f);
                    scale.Y       -= 12 * Transform.Scale.Y;
                    source.Height -= 12;
                    Renderer.FillTexture(texture, ShapeFactory.Rectangle, ref pos, ref scale, ref rot, ref offset, ref source, ref _colour);
                    pos.Y        += scale.Y;
                    scale.Y       = 12 * Transform.Scale.Y;
                    source.Y     += source.Height;
                    source.Height = 12;
                    Renderer.FillTexture(texture, ShapeFactory.Rectangle, ref pos, ref scale, ref rot, ref offset, ref source, ref color2);
                }
            }
        }
Example #2
0
 public SpriteData GetSpriteData()
 {
     return(SpriteData.GetSpriteData(_spriteID));
 }