예제 #1
0
 public void Draw(SpriteBatch batch, float offsetX, float offsetY)
 {
     if (alpha != 1f)
     {
         batch.SetAlpha(alpha);
     }
     if (!filterColor.Equals(1f, 1f, 1f, 1f))
     {
         batch.SetColor(filterColor);
     }
     if (scaleX == 1 && scaleY == 1)
     {
         if (mirror)
         {
             if (GetRotation() != 0)
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, GetRotation());
                 }
                 else
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, dstWidth,
                                     dstHeight, GetRotation());
                 }
             }
             else
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY);
                 }
                 else
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, dstWidth,
                                     dstHeight);
                 }
             }
         }
         else
         {
             if (GetRotation() != 0)
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY,
                                GetRotation());
                 }
                 else
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, dstWidth,
                                dstHeight, GetRotation());
                 }
             }
             else
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY);
                 }
                 else
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, dstWidth,
                                dstHeight);
                 }
             }
         }
     }
     else
     {
         float width  = animation.GetSpriteImage().GetWidth();
         float height = animation.GetSpriteImage().GetHeight();
         if (mirror)
         {
             if (GetRotation() != 0)
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, width * scaleX,
                                     height * scaleY, GetRotation());
                 }
                 else
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, dstWidth * scaleX,
                                     dstHeight * scaleY, GetRotation());
                 }
             }
             else
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, width * scaleX, height * scaleY,
                                     GetY() + offsetY);
                 }
                 else
                 {
                     batch.DrawFlipX(animation.GetSpriteImage(), GetX()
                                     + offsetX, GetY() + offsetY, dstWidth * scaleX,
                                     dstHeight * scaleY);
                 }
             }
         }
         else
         {
             if (GetRotation() != 0)
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, width
                                * scaleX, height * scaleY,
                                GetRotation());
                 }
                 else
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, dstWidth
                                * scaleX, dstHeight * scaleY,
                                GetRotation());
                 }
             }
             else
             {
                 if (dstWidth < 1 && dstHeight < 1)
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, width
                                * scaleX, height * scaleY);
                 }
                 else
                 {
                     batch.Draw(animation.GetSpriteImage(),
                                GetX() + offsetX, GetY() + offsetY, dstWidth
                                * scaleX, dstHeight * scaleY);
                 }
             }
         }
     }
     if (alpha != 1f || !filterColor.Equals(1f, 1f, 1f, 1f))
     {
         batch.ResetColor();
     }
 }