This commit is contained in:
IbanPlay committed 2022-01-21 02:22:40 +01:00
1 parent 544901aee0
commit 97af1e172b
4 files changed
+83 -4

No files matched your search

+11 -1
View File
@@ -601,6 +601,16 @@ namespace CalamityMod.Items.Weapons.Melee
}
}
if (ChannelTimer >= ChannelTime - 15)
{
Vector2 Shake = Main.rand.NextVector2Circular(6f, 6f);
projectile.Center += Shake;
Vector2 Bottom = projectile.Center + Vector2.UnitY * 20f;
Particle Sparkle = new ElectricSpark(Bottom, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(10f, 20f), Color.White, Main.rand.NextBool() ? Main.rand.NextBool() ? Color.Goldenrod : Color.GreenYellow : Main.rand.NextBool() ? Color.Cyan : Color.Magenta, 1f + Main.rand.NextFloat(0f, 1f), 34, rotationSpeed : 0.1f, bloomScale : 4f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
if (ChannelTimer >= ChannelTime)
{
projectile.timeLeft = 60;
@@ -646,7 +656,7 @@ namespace CalamityMod.Items.Weapons.Melee
}
//Chunger
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThunderStrike"), projectile.Center);
Particle thunder = new ThunderBoltVFX(projectile.Center + Vector2.UnitY * 20f, Main.rand.NextBool() ? Main.rand.NextBool() ? Color.Goldenrod : Color.GreenYellow : Main.rand.NextBool() ? Color.Cyan : Color.Magenta, 0f, 1.5f, Vector2.One, 1f, 20f, projectile, 20f);
Particle thunder = new ThunderBoltVFX(projectile.Center + Vector2.UnitY * 20f, Main.rand.NextBool() ? Main.rand.NextBool() ? Color.Goldenrod : Color.GreenYellow : Main.rand.NextBool() ? Color.Cyan : Color.Magenta, 0f, 1.5f, Vector2.One, 1f, 15f, projectile, 20f);
GeneralParticleHandler.SpawnParticle(thunder);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 5)
+69
View File
@@ -0,0 +1,69 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class ElectricSpark : Particle
{
public override string Texture => "CalamityMod/Particles/ElectricSpark";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override int FrameVariants => 2;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
private float MaxJumpRotation; //Max rotation that the particle can change velocity per "jump"
private float JumpTime; //Time between jumps
private Vector2 OriginalSpeed;
public ElectricSpark(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float maxJumpRotation = MathHelper.PiOver4, float jumpTime = 10, float rotationSpeed = 1f, float bloomScale = 1f)
{
Position = position;
Velocity = velocity;
OriginalSpeed = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
MaxJumpRotation = maxJumpRotation;
JumpTime = jumpTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
Variant = Main.rand.Next(2);
}
public override void Update()
{
opacity -= JumpTime * 0.25f / Lifetime;
if (Time % JumpTime == 0)
{
opacity = 1f;
Velocity = OriginalSpeed.RotatedByRandom(MaxJumpRotation);
}
Velocity *= 0.6f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f) * (LifetimeCompletion > 0.5 ? 1f : 0.5f);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D sparkTexture = GeneralParticleHandler.GetTexture(Type);
Rectangle frame = new Rectangle(0, 6 * Variant, 6, 6);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)frame.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(sparkTexture, Position - Main.screenPosition, frame, Color * opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

+3 -3
View File
@@ -32,13 +32,13 @@ namespace CalamityMod.Particles
if (projectileToFollow != null)
AttachedProjectile = projectileToFollow;
DisplacementFromProjectile = displacementFromProjectile;
Lifetime = 15;
Lifetime = 30;
}
public override void Update()
{
Lighting.AddLight(Position, Color.ToVector3() * 3f);
float fadeFactor = 1f - 0.05f * MathHelper.Clamp((Time - 8) / 7f, 0f, 1f);
float fadeFactor = 1f - 0.05f * MathHelper.Clamp((Time - 10) / 10f, 0f, 1f);
Opacity *= fadeFactor;
Squish.X *= fadeFactor;
@@ -57,7 +57,7 @@ namespace CalamityMod.Particles
Color drawColor = Color.Lerp(Color.White, Color, (Time / (float)Lifetime));
SpriteEffects flip = (Main.GlobalTime % 15 < 7) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
SpriteEffects flip = (Main.GlobalTime % 30 < 15) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(tex, Position + Shake - Main.screenPosition, null, Color * Opacity * 0.6f, Rotation, Origin, Squish * Scale, flip, 0);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, drawColor * Opacity, Rotation, Origin, Squish * Scale, flip, 0);