Files
CalamityModPublic/Projectiles/Magic/SHPL.cs
T

82 lines
2.5 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class SHPL : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/LaserProj";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Laser");
}
public override void SetDefaults()
{
Projectile.width = 5;
Projectile.height = 5;
Projectile.friendly = true;
Projectile.alpha = 255;
Projectile.penetrate = 1;
Projectile.extraUpdates = 3;
Projectile.timeLeft = 600;
Projectile.DamageType = DamageClass.Magic;
}
public override void AI()
{
if (Projectile.alpha > 0)
{
Projectile.alpha -= 25;
}
if (Projectile.alpha < 0)
{
Projectile.alpha = 0;
}
Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0.5f, 0.2f, 0.5f);
float num55 = 100f;
float num56 = 3f;
if (Projectile.ai[1] == 0f)
{
Projectile.localAI[0] += num56;
if (Projectile.localAI[0] > num55)
{
Projectile.localAI[0] = num55;
}
}
else
{
Projectile.localAI[0] -= num56;
if (Projectile.localAI[0] <= 0f)
{
Projectile.Kill();
return;
}
}
}
public override Color? GetAlpha(Color lightColor) => new Color(255, Main.DiscoG, 155, Projectile.alpha);
public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor);
public override void Kill(int timeLeft)
{
int dustAmt = Main.rand.Next(3, 7);
for (int d = 0; d < dustAmt; d++)
{
int dustType = Utils.SelectRandom(Main.rand, new int[]
{
246,
73,
187
});
int idx = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, dustType, 0f, 0f, 100, default, 2.1f);
Main.dust[idx].velocity *= 2f;
Main.dust[idx].noGravity = true;
}
}
}
}