public void AdditiveCall(SpriteBatch spriteBatch) { float blurLength = 100 * projectile.scale; float blurWidth = 5 * projectile.scale; float flickerStrength = (((float)Math.Sin(Main.GlobalTime * 10) % 1) * 0.1f) + 1f; Effect blurEffect = mod.GetEffect("Effects/BlurLine"); IPrimitiveShape[] blurLines = new IPrimitiveShape[] { //Horizontal new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength, Rotation = 0, Color = Color.White * flickerStrength * projectile.Opacity }, //Vertical, lower length new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength * 0.5f, Rotation = MathHelper.PiOver2, Color = Color.White * flickerStrength * projectile.Opacity }, }; PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (projectile.timeLeft > 2) //bandaid fix for flickering { return(false); } float opacity = projectile.Opacity; float xMod = (1 + (Distance / 250) + (SwingRadians / GranitechSaberProjectile.SwingRadians)); Effect effect = mod.GetEffect("Effects/GSaber"); effect.Parameters["baseTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_2")); effect.Parameters["baseColor"].SetValue(new Color(25, 132, 247).ToVector4()); effect.Parameters["overlayTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_1")); effect.Parameters["overlayColor"].SetValue(new Color(99, 255, 229).ToVector4()); effect.Parameters["xMod"].SetValue(1.5f * xMod); //scale with the total length of the strip effect.Parameters["yMod"].SetValue(2.5f); float slashProgress = EaseFunction.EaseCircularInOut.Ease(Timer / SwingTime); effect.Parameters["timer"].SetValue(-Main.GlobalTime * 6); effect.Parameters["progress"].SetValue(slashProgress); Vector2 pos = BasePosition - Main.screenPosition; List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>(); DrawAberration.DrawChromaticAberration(Vector2.UnitX, 4, delegate(Vector2 offset, Color colorMod) { PrimitiveSlashArc slash = new PrimitiveSlashArc { BasePosition = pos, StartDistance = offset.X + Distance - projectile.Size.Length() / 2 * SwingDirection, EndDistance = offset.X + Distance + projectile.Size.Length() / 2 * SwingDirection, AngleRange = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection), DirectionUnit = InitialVelocity, Color = colorMod * opacity * 0.5f, SlashProgress = slashProgress }; slashArcs.Add(slash); }); PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect); Texture2D tex = Main.projectileTexture[projectile.type]; SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; DrawAberration.DrawChromaticAberration(projectile.velocity, 3, delegate(Vector2 offset, Color colorMod) { spriteBatch.Draw(tex, projectile.Center + offset - Main.screenPosition, null, colorMod * opacity, projectile.rotation, tex.Size() / 2, projectile.scale, spriteEffects, 0); }); return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); Vector2 pos = Player.MountedCenter - Main.screenPosition; float progress = GetProgress(); List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>(); Effect effect = mod.GetEffect("Effects/NemesisBoonShader"); effect.Parameters["white"].SetValue(Color.OrangeRed.ToVector4()); effect.Parameters["opacity"].SetValue((float)Math.Sqrt(1 - progress)); PrimitiveSlashArc slash = new PrimitiveSlashArc { BasePosition = Player.Center - Main.screenPosition, StartDistance = (projectile.width * 0.3f) * projectile.scale, EndDistance = (projectile.width * 0.85f) * (((projectile.scale - 1) * 0.5f) + 1), AngleRange = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection), DirectionUnit = direction, Color = Color.Red, SlashProgress = progress }; slashArcs.Add(slash); PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); Texture2D tex2 = Main.projectileTexture[projectile.type]; Texture2D tex3 = ModContent.GetTexture(Texture + "_Glow"); if (flip) { if (Empowered) { spriteBatch.Draw(tex3, Player.Center - Main.screenPosition, null, Color.Red * (float)Math.Sqrt(1 - progress) * 0.3f, rotation + 2.355f, new Vector2(tex3.Width, tex3.Height), projectile.scale, SpriteEffects.FlipHorizontally, 0f); } spriteBatch.Draw(tex2, Player.Center - Main.screenPosition, null, lightColor * .5f, rotation + 2.355f, new Vector2(tex2.Width, tex2.Height), projectile.scale, SpriteEffects.FlipHorizontally, 0f); } else { if (Empowered) { spriteBatch.Draw(tex3, Player.Center - Main.screenPosition, null, Color.Red * (float)Math.Sqrt(1 - progress) * 0.3f, rotation + 0.785f, new Vector2(0, tex3.Height), projectile.scale, SpriteEffects.None, 0f); } spriteBatch.Draw(tex2, Player.Center - Main.screenPosition, null, lightColor, rotation + 0.785f, new Vector2(0, tex2.Height), projectile.scale, SpriteEffects.None, 0f); } return(false); }
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 override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); float opacity = (float)Math.Pow(Math.Sin(Timer * MathHelper.Pi / swingTime), 1.5f) * 0.75f; Effect effect = mod.GetEffect("Effects/GSaber"); effect.Parameters["baseTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_2")); effect.Parameters["baseColor"].SetValue(new Color(25, 132, 247).ToVector4()); effect.Parameters["overlayTexture"].SetValue(mod.GetTexture("Textures/GeometricTexture_1")); effect.Parameters["overlayColor"].SetValue(new Color(99, 255, 229).ToVector4()); effect.Parameters["xMod"].SetValue(1.5f); effect.Parameters["yMod"].SetValue(2.5f); float slashProgress = EaseFunction.EaseCircularInOut.Ease(Timer / swingTime); effect.Parameters["timer"].SetValue(-Main.GlobalTime * 6); effect.Parameters["progress"].SetValue(slashProgress); Vector2 pos = Owner.MountedCenter - Main.screenPosition; List <PrimitiveSlashArc> slashArcs = new List <PrimitiveSlashArc>(); DrawAberration.DrawChromaticAberration(Vector2.UnitX, 2, delegate(Vector2 offset, Color colorMod) { PrimitiveSlashArc slash = new PrimitiveSlashArc { BasePosition = pos, StartDistance = offset.X + projectile.Size.Length() * 0.33f, EndDistance = offset.X + projectile.Size.Length(), AngleRange = new Vector2(SwingRadians / 2 * SwingDirection, -SwingRadians / 2 * SwingDirection), DirectionUnit = initialVelocity, Color = colorMod * opacity, SlashProgress = slashProgress }; slashArcs.Add(slash); }); PrimitiveRenderer.DrawPrimitiveShapeBatched(slashArcs.ToArray(), effect); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); return(base.PreDraw(spriteBatch, lightColor)); }
public override void Draw(Effect effect, BasicEffect effect2, GraphicsDevice device) { if (Dead || _points.Count <= 1) { return; } //set the parameters for the shader Effect flametrailEffect = SpiritMod.Instance.GetEffect("Effects/FlameTrail"); flametrailEffect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_3")); flametrailEffect.Parameters["uTexture2"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_4")); flametrailEffect.Parameters["Progress"].SetValue(Main.GlobalTime * -1f); flametrailEffect.Parameters["xMod"].SetValue(1.5f); flametrailEffect.Parameters["StartColor"].SetValue(_startColor.ToVector4()); flametrailEffect.Parameters["MidColor"].SetValue(_midColor.ToVector4()); flametrailEffect.Parameters["EndColor"].SetValue(_endColor.ToVector4()); float getWidthMod(float progress = 0) => ((float)Math.Sin((Main.GlobalTime - progress) * MathHelper.TwoPi * 1.5f) * 0.33f + 1.33f) / (float)Math.Pow(1 - progress, 0.1f); IPrimitiveShape[] shapesToDraw = new IPrimitiveShape[] { new CirclePrimitive { Color = Color.White * _deathProgress, Radius = _width * _deathProgress * getWidthMod(), Position = _points[0] - Main.screenPosition, MaxRadians = MathHelper.TwoPi }, new PrimitiveStrip { Color = Color.White * _deathProgress, Width = _width * _deathProgress, PositionArray = _points.ToArray(), TaperingType = StripTaperType.TaperEnd, WidthDelegate = delegate(float progress) { return(getWidthMod(progress)); } } }; PrimitiveRenderer.DrawPrimitiveShapeBatched(shapesToDraw, flametrailEffect); }
public void AdditiveCall(SpriteBatch sB) { float blurLength = 180 * projectile.scale; float blurWidth = 8 * projectile.scale; float flickerStrength = (((float)Math.Sin(Main.GlobalTime * 12) % 1) * 0.1f) + 1f; Effect blurEffect = mod.GetEffect("Effects/BlurLine"); IPrimitiveShape[] blurLines = new IPrimitiveShape[] { //Horizontal new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength, Rotation = 0, Color = Color.White * flickerStrength * projectile.Opacity }, //Vertical, lower length new SquarePrimitive() { Position = projectile.Center - Main.screenPosition, Height = blurWidth * flickerStrength, Length = blurLength * flickerStrength * 0.75f, Rotation = MathHelper.PiOver2, Color = Color.White * flickerStrength * projectile.Opacity }, }; PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect); Texture2D bloom = mod.GetTexture("Effects/Masks/CircleGradient"); sB.Draw(bloom, projectile.Center - Main.screenPosition, null, Color.White * projectile.Opacity, 0, bloom.Size() / 2, 0.25f * projectile.scale, SpriteEffects.None, 0); }