using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.GameContent;
namespace Vanniluxe.Content.Projectiles.OnFireFlamethrower
{
public class OnFireFlamethrower : ModProjectile
{
public override void SetStaticDefaults() {
Main.projFrames[Projectile.type] = 7;
}
public override void SetDefaults() {
Projectile.width = 80;
Projectile.height = 80;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Ranged;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = 4;
Projectile.alpha = 0;
}
public override Color? GetAlpha(Color lightColor) {
return new Color(255, 255, 255, 0) * Projectile.Opacity;
}
public override void AI() {
Projectile.ai[0] += 2f;
FadeInAndOut();
Projectile.velocity *= 1;
if (++Projectile.frameCounter >=8) {
Projectile.frameCounter = 0;
if (++Projectile.frame >= Main.projFrames[Projectile.type])
Projectile.frame = 0;
}
if (Projectile.ai[0] >= 100f)
Projectile.Kill();
Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f) ? 1 : -1;
Projectile.rotation = Projectile.velocity.ToRotation();
if (Projectile.spriteDirection == -1) {
Projectile.rotation += MathHelper.Pi;
if (Main.netMode != NetmodeID.Server)
{
Dust dust = Dust.NewDustPerfect(
Position: Projectile.Center,
Type: DustID.Torch,
Velocity: Vector2.Zero,
Alpha: 100,
newColor: Color.Orange,
Scale: 0.6f
);
dust.noGravity = true;
dust.fadeIn = -1f;
}
}
}
public void FadeInAndOut() {
if (Projectile.ai[0] <= 90f) {
Projectile.alpha -= 50;
if (Projectile.alpha < 100)
Projectile.alpha = 100;
return;
}
Projectile.alpha += 50;
if (Projectile.alpha > 255)
Projectile.alpha = 255;
}
}
}