示例#1
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            // need to draw sprites manually for some reason
            float         r           = projectile.rotation;
            Vector2       pos         = projectile.Center;
            SpriteEffects effects     = projectile.velocity.X < 0 ? SpriteEffects.FlipVertically : 0;
            Texture2D     texture     = GetTexture(Texture);
            int           frameHeight = texture.Height / Main.projFrames[projectile.type];
            Rectangle     bounds      = new Rectangle(0, projectile.frame * frameHeight, texture.Width, frameHeight);
            Vector2       origin      = new Vector2(bounds.Width / 2, bounds.Height / 2);

            // motion blur
            if (isDashing)
            {
                // lifted from ExampleMod's ExampleBullet
                for (int k = 0; k < blurHelper.BlurLength; k++)
                {
                    if (!blurHelper.GetBlurPosAndColor(k, lightColor, out Vector2 blurPos, out Color blurColor))
                    {
                        break;
                    }
                    blurPos = blurPos - Main.screenPosition + origin;
                    spriteBatch.Draw(texture, blurPos, bounds, blurColor, r, origin, 1, effects, 0);
                }
            }
            // regular version
            spriteBatch.Draw(texture, pos - Main.screenPosition,
                             bounds, lightColor, r, origin, 1, effects, 0);
            return(false);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture     = Main.projectileTexture[Projectile.type];
            int       frameHeight = texture.Height / Main.projFrames[Projectile.type];

            for (int k = 0; k < blurDrawer.BlurLength; k++)
            {
                if (!blurDrawer.GetBlurPosAndColor(k, lightColor, out Vector2 blurPos, out Color blurColor))
                {
                    break;
                }
                Rectangle bounds = new Rectangle(0, Projectile.frame * frameHeight, texture.Width, frameHeight);
                Vector2   origin = new Vector2(bounds.Width / 2, bounds.Height / 2);
                blurPos -= Main.screenPosition;
                spriteBatch.Draw(texture, blurPos, bounds, blurColor, Projectile.rotation, origin, 1, 0, 0);
            }
            return(false);
        }
        // for layering purposes, this needs to be done manually
        // Called from TerrarianEnt.PreDraw
        public void SubPreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            // this is a lot of sprite drawing
            // lifted from ExampleMod's ExampleBullet
            int attackFrame = animationFrame - targetStartFrame;

            if (targetStartFrame != default && attackFrame > windupFrames)
            {
                for (int k = 0; k < blurHelper.BlurLength; k++)
                {
                    if (!blurHelper.GetBlurPosAndColor(k, lightColor, out Vector2 blurPos, out Color blurColor))
                    {
                        break;
                    }
                    scHelper.positionOverride = blurPos;
                    scHelper.Draw(spriteBatch, blurColor * 0.25f);
                }
            }
            scHelper.positionOverride = null;
            scHelper.Draw(spriteBatch, lightColor);
        }
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            float     r       = projectile.rotation;
            Vector2   pos     = projectile.Center;
            Texture2D texture = Main.projectileTexture[projectile.type];

            for (int i = 0; i < blurDrawer.BlurLength; i++)
            {
                if (!blurDrawer.GetBlurPosAndColor(i, Color.White, out Vector2 blurPos, out Color blurColor))
                {
                    break;
                }
                float scale = MathHelper.Lerp(0.75f, 0.25f, i / (float)blurDrawer.BlurLength);
                spriteBatch.Draw(texture, blurPos - Main.screenPosition,
                                 texture.Bounds, blurColor * 0.5f, r,
                                 texture.Bounds.Center(), scale, 0, 0);
            }
            spriteBatch.Draw(texture, pos - Main.screenPosition,
                             texture.Bounds, Color.White, r,
                             texture.Bounds.Center(), 0.75f, 0, 0);
            return(false);
        }
 public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
 {
     if (usingSpecial)
     {
         if (isDashing)
         {
             for (int k = 0; k < blurHelper.BlurLength; k++)
             {
                 if (!blurHelper.GetBlurPosAndColor(k, lightColor, out Vector2 blurPos, out Color blurColor))
                 {
                     break;
                 }
                 DrawHorse(spriteBatch, blurColor, blurPos);
             }
         }
     }
     else
     {
         base.PreDraw(spriteBatch, lightColor);
     }
     return(true);
 }