55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class SandTooth : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Boss";
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 20;
|
|
Projectile.height = 20;
|
|
Projectile.hostile = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
int num103 = Player.FindClosest(Projectile.Center, 1, 1);
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] < 150f && Projectile.ai[1] > 30f)
|
|
{
|
|
float inertia = 30f;
|
|
float scaleFactor2 = Projectile.velocity.Length();
|
|
Vector2 vector11 = Main.player[num103].Center - Projectile.Center;
|
|
vector11.Normalize();
|
|
vector11 *= scaleFactor2;
|
|
Projectile.velocity = (Projectile.velocity * (inertia - 1f) + vector11) / inertia;
|
|
Projectile.velocity.Normalize();
|
|
Projectile.velocity *= scaleFactor2;
|
|
}
|
|
else if (Projectile.ai[0] == 1f)
|
|
{
|
|
if (Projectile.velocity.Length() < 16f)
|
|
Projectile.velocity *= 1.01f;
|
|
}
|
|
|
|
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver4;
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
lightColor.R = (byte)(255 * Projectile.Opacity);
|
|
lightColor.G = (byte)(255 * Projectile.Opacity);
|
|
lightColor.B = (byte)(255 * Projectile.Opacity);
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
}
|
|
}
|