63 lines
2.5 KiB
C#
63 lines
2.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class PlasmaRay2 : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.friendly = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.penetrate = 1;
|
|
Projectile.extraUpdates = 100;
|
|
Projectile.timeLeft = 40;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.DemonTorch, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
|
|
if (Projectile.velocity.X != Projectile.velocity.X)
|
|
{
|
|
Projectile.position.X = Projectile.position.X + Projectile.velocity.X;
|
|
Projectile.velocity.X = -Projectile.velocity.X;
|
|
}
|
|
if (Projectile.velocity.Y != Projectile.velocity.Y)
|
|
{
|
|
Projectile.position.Y = Projectile.position.Y + Projectile.velocity.Y;
|
|
Projectile.velocity.Y = -Projectile.velocity.Y;
|
|
}
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 9f)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector2 projPos = Projectile.position;
|
|
projPos -= Projectile.velocity * ((float)i * 0.25f);
|
|
Projectile.alpha = 255;
|
|
int purpDust = Dust.NewDust(projPos, 1, 1, DustID.ShadowbeamStaff, 0f, 0f, 0, default, 0.25f);
|
|
Main.dust[purpDust].position = projPos;
|
|
Main.dust[purpDust].scale = (float)Main.rand.Next(70, 110) * 0.013f;
|
|
Main.dust[purpDust].velocity *= 0.2f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 3; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.DemonTorch, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
}
|
|
}
|