Ejemplo n.º 1
0
        void DrawClsnBoxes(Vector2 location, Animations.AnimationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            Video.DrawState drawstate = SpriteManager.DrawState;
            drawstate.Reset();

            drawstate.Mode = DrawMode.OutlinedRectangle;

            foreach (Animations.Clsn clsn in element)
            {
                Rectangle rect = clsn.MakeRect(location, CurrentScale, CurrentFacing);

                switch (clsn.ClsnType)
                {
                case ClsnType.Type1Attack:
                    drawstate.AddData(new Vector2(rect.X, rect.Y), new Rectangle(0, 0, rect.Width, rect.Height), Color.Red);
                    break;

                case ClsnType.Type2Normal:
                    drawstate.AddData(new Vector2(rect.X, rect.Y), new Rectangle(0, 0, rect.Width, rect.Height), Color.Blue);
                    break;
                }
            }

            drawstate.Use();
        }
Ejemplo n.º 2
0
        public SpriteEffects GetDrawFlip()
        {
            Animations.AnimationElement currentelement = AnimationManager.CurrentElement;

            SpriteEffects flip = CurrentFlip ^ currentelement.Flip;

            if (CurrentFacing == Facing.Left)
            {
                flip ^= SpriteEffects.FlipHorizontally;
            }

            return(flip);
        }
Ejemplo n.º 3
0
        public virtual void DebugDraw()
        {
            Animations.AnimationElement currentelement = AnimationManager.CurrentElement;
            if (currentelement == null)
            {
                return;
            }

            Vector2 location = GetDrawLocation();

            //DrawSpriteBox(location, currentelement);
            DrawClsnBoxes(location, currentelement);
            DrawOriginCross(location, 3);
        }
Ejemplo n.º 4
0
        private void DrawSpriteBox(Vector2 location, Animations.AnimationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            var sprite = SpriteManager.GetSprite(element.SpriteId);

            if (sprite == null)
            {
                return;
            }

            var drawoffset = Vector2.Zero;
            var flip       = GetDrawFlip();

            switch (CurrentFacing)
            {
            case Facing.Right:
                drawoffset = element.Offset;
                break;

            case Facing.Left:
                drawoffset = new Vector2(-element.Offset.X, element.Offset.Y);
                break;
            }

            if ((flip & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally)
            {
                drawoffset.X = -drawoffset.X;
            }
            if ((flip & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically)
            {
                drawoffset.Y = -drawoffset.Y;
            }

            var drawstate = SpriteManager.DrawState;

            var spritelocation = Video.Renderer.GetDrawLocation(sprite.Size, location, (Vector2)sprite.Axis - drawoffset, CurrentScale, flip);

            drawstate.Reset();
            drawstate.Mode = DrawMode.OutlinedRectangle;
            drawstate.AddData(spritelocation, new Rectangle(0, 0, (int)(sprite.Size.X * CurrentScale.X), (int)(sprite.Size.Y * CurrentScale.Y)), Color.Gray);
            drawstate.Use();
        }
Ejemplo n.º 5
0
        public override void Draw(Vector2 location)
        {
            if (AnimationManager.HasAnimation(DataMap.AnimationNumber) == true)
            {
                Animations.AnimationElement element = AnimationManager.CurrentElement;
                if (element == null)
                {
                    return;
                }

                Drawing.Sprite sprite = SpriteManager.GetSprite(element.SpriteId);
                if (sprite == null)
                {
                    return;
                }

                Video.DrawState drawstate = SpriteManager.SetupDrawing(element.SpriteId, location, DataMap.Offset + element.Offset, DataMap.Scale, DataMap.Flip);
                drawstate.Blending = element.Blending;
                drawstate.Use();
            }
        }
Ejemplo n.º 6
0
        public virtual void Draw()
        {
            AfterImages.Draw();

            Animations.AnimationElement currentelement = AnimationManager.CurrentElement;
            if (currentelement == null)
            {
                return;
            }

            Drawing.Sprite sprite = SpriteManager.GetSprite(currentelement.SpriteId);
            if (sprite == null)
            {
                return;
            }

            Vector2 drawlocation = GetDrawLocation();
            Vector2 drawoffset   = Misc.GetOffset(Vector2.Zero, CurrentFacing, currentelement.Offset);

            SpriteManager.OverridePalette = CurrentPalette;

            Vector2 drawscale = CurrentScale;

            if (this is Character)
            {
                drawscale *= (this as Character).DrawScale;
            }

            Video.DrawState drawstate = SpriteManager.SetupDrawing(currentelement.SpriteId, drawlocation, drawoffset, drawscale, GetDrawFlip());

            drawstate.Blending = Transparency == new Blending() ? currentelement.Blending : Transparency;
            drawstate.Rotation = (AngleDraw == true) ? Misc.FaceScalar(CurrentFacing, -DrawingAngle) : 0;

            PaletteFx.SetShader(drawstate.ShaderParameters);

            drawstate.Use();
        }