public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (WeaverNPC == null) { return(false); } Texture2D ripple = mod.GetTexture("Effects/Ripple"); //Draw trail when returning to npc for (int i = 0; i < TrailLength; i++) { Vector2 position = projectile.oldPos[i] + projectile.Size / 2; float rotation = projectile.oldRot[i]; float scale = (TrailLength - i) / (float)TrailLength; float opacity = TrailProgress * scale; spriteBatch.Draw(ripple, position - Main.screenPosition, null, projectile.GetAlpha(Color.Red) * TrailProgress, 0, ripple.Size() / 2, 1.5f * scale, SpriteEffects.None, 0); spriteBatch.Draw(Main.projectileTexture[projectile.type], position - Main.screenPosition, projectile.DrawFrame(), projectile.GetAlpha(Color.Lerp(lightColor, Color.White, 0.5f)) * opacity, rotation, projectile.DrawFrame().Size() / 2, projectile.scale * scale, SpriteEffects.None, 0); spriteBatch.Draw(ModContent.GetTexture(Texture + "_glowRed"), position - Main.screenPosition, projectile.DrawFrame(), projectile.GetAlpha(Color.White) * opacity, rotation, projectile.DrawFrame().Size() / 2, projectile.scale * scale, SpriteEffects.None, 0); } spriteBatch.Draw(ripple, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(Color.Red) * TrailProgress, 0, ripple.Size() / 2, 1.5f, SpriteEffects.None, 0); Color bloomColor = Color.White; bloomColor.A = 0; float AttackProgress = StarWeaverNPC.GetBloomIntensity(WeaverNPC); //Glowy bloom during parent's starburst attacks spriteBatch.Draw(ripple, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(Color.Gold) * (1 - TrailProgress) * AttackProgress, 0, ripple.Size() / 2, 1.5f, SpriteEffects.None, 0); SpriteEffects flip = (projectile.spriteDirection < 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; //Bloom glowmask PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 12, 12, delegate(Vector2 posOffset, float opacityMod) { spriteBatch.Draw(ModContent.GetTexture(Texture + "_glow"), projectile.Center - Main.screenPosition + posOffset, projectile.DrawFrame(), projectile.GetAlpha(bloomColor) * (1 - TrailProgress) * AttackProgress * opacityMod, projectile.rotation, projectile.DrawFrame().Size() / 2, projectile.scale, flip, 0); }); projectile.QuickDraw(spriteBatch, drawColor: projectile.GetAlpha(Color.Lerp(lightColor, Color.White, 0.5f))); Color glowmaskColor = Color.Lerp(Color.White, bloomColor, AttackProgress); projectile.QuickDrawGlow(spriteBatch, projectile.GetAlpha(glowmaskColor) * (1 - TrailProgress)); spriteBatch.Draw(ModContent.GetTexture(Texture + "_glowRed"), projectile.Center - Main.screenPosition, projectile.DrawFrame(), projectile.GetAlpha(Color.White) * TrailProgress, projectile.rotation, projectile.DrawFrame().Size() / 2, projectile.scale, flip, 0); return(false); }
public static void DrawAfterImage(SpriteBatch spriteBatch, Texture2D tex, Vector2 position, Rectangle frame, Vector2 offset, float opacity, float rotation, float scale, Vector2 origin, SpriteEffects effects) { float baseOpacity = 0.75f; PulseDraw.DrawPulseEffect((float)Math.Asin(-0.6f), 12, 35, delegate(Vector2 posOffset, float pulseEffectOpacity) { spriteBatch.Draw(tex, position + offset + posOffset - Main.screenPosition, frame, new Color(230, 55, 166) * baseOpacity * opacity * pulseEffectOpacity, rotation, origin, scale, effects, 0f); }); }
public void AdditiveCall(SpriteBatch sB) { Texture2D whiteGlow = ModContent.GetTexture(Texture + "_glowWhite"); Color additiveGlow = _attackGlowColor; PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 6, delegate(Vector2 posOffset, float opacityMod) { DrawGlowmask(sB, whiteGlow, posOffset + npc.Center, additiveGlow, opacityMod * _attackGlowStrength * 0.33f); }); DrawGlowmask(sB, whiteGlow, npc.Center, additiveGlow, _attackGlowStrength); }
public override void CustomDraw(SpriteBatch spriteBatch) { //Draw a bloom underneath the circle Texture2D bloom = SpiritMod.Instance.GetTexture("Effects/Masks/CircleGradient"); Vector2 drawCenter = Position - Main.screenPosition; Vector2 bloomScale = new Vector2(Scale, Scale * (1 - _zRotation)); bloomScale *= 2.5f; Rectangle destRect = new Rectangle((int)(drawCenter.X - (bloomScale.X / 2)), (int)(drawCenter.Y - (bloomScale.Y / 2)), (int)bloomScale.X, (int)bloomScale.Y); spriteBatch.Draw(bloom, destRect, Color.Lerp(Color, Color.White, 0.25f) * _opacity * 0.4f); //Draw the circle itself Effect effect = SpiritMod.Instance.GetEffect("Effects/MagicCircle"); effect.Parameters["rotation"].SetValue(_rotation); Color additiveColor = Color; additiveColor.A = 0; effect.Parameters["uTexture"].SetValue(ParticleHandler.GetTexture(Type)); List <SquarePrimitive> primList = new List <SquarePrimitive>(); PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 6, delegate(Vector2 posOffset, float bloomOpacity) { primList.Add(new SquarePrimitive { Color = additiveColor * _opacity * bloomOpacity * 0.25f, Height = Scale, Length = Scale * (1 - _zRotation), Position = Position - Main.screenPosition + posOffset, Rotation = _angle, ColorXCoordMod = 1 - _zRotation }); }); primList.Add(new SquarePrimitive { Color = additiveColor * _opacity, Height = Scale, Length = Scale * (1 - _zRotation), Position = Position - Main.screenPosition, Rotation = _angle, ColorXCoordMod = 1 - _zRotation }); PrimitiveRenderer.DrawPrimitiveShapeBatched(primList.ToArray(), effect); }
public void AdditiveCall(SpriteBatch sB) { //Adjust framing due to secondary column Rectangle frame = projectile.DrawFrame(); void Draw(Vector2 offset, float opacity) { sB.Draw(Main.projectileTexture[projectile.type], projectile.Center + offset - Main.screenPosition, frame, Color.White * opacity, projectile.rotation, new Vector2(frame.Width * 0.8f, frame.Height * 0.5f), projectile.scale, SpriteEffects.None, 0); } PulseDraw.DrawPulseEffect((float)Math.Asin(-0.6), 8, 12, delegate(Vector2 posOffset, float opacityMod) { Draw(posOffset, opacityMod * 0.33f); }); Draw(Vector2.Zero, 1); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { float glowStrength = 0; float glowStrengthMin = 0.1f; if (UseProgress < DRAWBACK_TIME) { glowStrength = EaseFunction.EaseCircularIn.Ease(UseProgress / DRAWBACK_TIME) * glowStrengthMin; //Increase strength while drawing back until reaching the minimum } else { glowStrength = EaseFunction.EaseCircularOut.Ease((UseProgress - DRAWBACK_TIME) / SWING_TIME); //Make glow strength proportional to progress through the swing glowStrength = 1 - (2 * Math.Abs(glowStrength - 0.5f)); //Then, use an absolute value function to make it peak in strength midway, rather than the end glowStrength = EaseFunction.EaseCircularInOut.Ease(glowStrength); //Then smooth it out with an easing function DrawTrail(spriteBatch, lightColor, EaseFunction.EaseCircularOut.Ease((UseProgress - DRAWBACK_TIME) / SWING_TIME), Math.Min(glowStrength * 5, 1)); glowStrength = Math.Max(glowStrength, glowStrengthMin); //Finally, if too low, increase it } Texture2D projGlow = ModContent.GetTexture(Texture + "_glow"); Texture2D projMask = ModContent.GetTexture(Texture + "_mask"); Color additiveWhite = new Color(255, 255, 255, 0) * glowStrength; void DrawGlow(Texture2D tex, Vector2?offset = null, float opacityMod = 1f) => //Use a method for a bit less copy paste spriteBatch.Draw(tex, projectile.Center + (offset ?? Vector2.Zero) - Main.screenPosition, null, additiveWhite * opacityMod, projectile.rotation, tex.Size() / 2, projectile.scale, projectile.spriteDirection < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); //Draw mask behind the sword PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 10, delegate(Vector2 offset, float opacityMod) { DrawGlow(projMask, offset, opacityMod * 0.8f); }); DrawGlow(projMask); projectile.QuickDraw(spriteBatch); //Draw glowmask above the sword PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 6, delegate(Vector2 offset, float opacityMod) { DrawGlow(projGlow, offset, opacityMod * 0.66f); }); DrawGlow(projGlow); return(false); }
public void DrawAdditiveLayer(SpriteBatch sB) { Texture2D glowmask = mod.GetTexture(GlowmaskPath); if (!CanDraw) { return; } SpriteEffects effects = player.direction > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Vector2 offset = HoldOffset(); PulseDraw.DrawPulseEffect((float)Math.Asin(-0.6), 8, 12, delegate(Vector2 posOffset, float opacityMod) { sB.Draw(glowmask, player.itemLocation + posOffset - Main.screenPosition + offset, DrawFrame, Color.White * opacityMod * 0.4f, player.itemRotation, TextureOrigin, player.HeldItem.scale, effects, 0); }); sB.Draw(glowmask, player.itemLocation - Main.screenPosition + offset, DrawFrame, Color.White * 0.7f, player.itemRotation, TextureOrigin, player.HeldItem.scale, effects, 0); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D Mask = ModContent.GetTexture(Texture + "_Glow"); projectile.QuickDraw(spriteBatch); void DrawGlow(Vector2 positionOffset, Color Color) => spriteBatch.Draw(Mask, projectile.Center - Main.screenPosition + positionOffset, projectile.DrawFrame(), Color, projectile.rotation, projectile.DrawFrame().Size() / 2, projectile.scale, SpriteEffects.None, 0); Color additiveWhite = Color.White; additiveWhite.A = 0; DrawGlow(Vector2.Zero, Color.White); PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 6, 6, delegate(Vector2 offset, float opacity) { DrawGlow(offset, additiveWhite * opacity * 0.5f); }); DrawGlow(Vector2.Zero, additiveWhite); return(false); }
public void DrawAdditiveLayer(SpriteBatch sB) { if (player.frozen || player.dead) { return; } Texture2D glow = mod.GetTexture(GlowmaskPath); Vector2 drawPosition = GetHoldPosition - Main.screenPosition; Item item = player.HeldItem; SpriteEffects flip = player.direction > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; PulseDraw.DrawPulseEffect((float)Math.Asin(-0.6), 8, 12, delegate(Vector2 posOffset, float opacityMod) { sB.Draw(glow, drawPosition + posOffset, DrawRectangle, Color.White * opacityMod * GlowmaskOpacity * 0.5f, 0, Origin, item.scale, flip, 0); }); sB.Draw(glow, drawPosition, DrawRectangle, Color.White * GlowmaskOpacity, 0, Origin, item.scale, flip, 0); DrawBeams(sB); }
public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { Vector2 scale = new Vector2(TeleportWidth(), 1) * npc.scale; Color bloomColor = Color.White; bloomColor.A = 0; float AttackProgress = GetBloomIntensity(this); PulseDraw.DrawPulseEffect(PulseDraw.BloomConstant, 12, 16, delegate(Vector2 posOffset, float opacityMod) { spriteBatch.Draw(ModContent.GetTexture(Texture + "_glow"), npc.Center + posOffset - Main.screenPosition, npc.frame, npc.GetAlpha(bloomColor) * opacityMod * AttackProgress, npc.rotation, npc.frame.Size() / 2, scale, (npc.spriteDirection > 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); }); Color glowmaskColor = Color.Lerp(Color.White, bloomColor, AttackProgress); spriteBatch.Draw(ModContent.GetTexture(Texture + "_glow"), npc.Center - Main.screenPosition, npc.frame, npc.GetAlpha(glowmaskColor), npc.rotation, npc.frame.Size() / 2, scale, (npc.spriteDirection > 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); spriteBatch.Draw(ModContent.GetTexture(Texture + "_mask"), npc.Center - Main.screenPosition, npc.frame, npc.GetAlpha(Color.White) * TeleportMaskOpacity(), npc.rotation, npc.frame.Size() / 2, scale, (npc.spriteDirection > 0) ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); }