65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class MirrorBlast : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Blast");
|
|
ProjectileID.Sets.TrailCacheLength[projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 12;
|
|
projectile.height = 12;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.melee = true;
|
|
projectile.penetrate = 1;
|
|
projectile.timeLeft = 300;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
int num123 = (int)Player.FindClosest(projectile.Center, 1, 1);
|
|
projectile.ai[1] += 1f;
|
|
if (projectile.ai[1] < 110f && projectile.ai[1] > 30f)
|
|
{
|
|
float scaleFactor2 = projectile.velocity.Length();
|
|
Vector2 vector17 = Main.player[num123].Center - projectile.Center;
|
|
vector17.Normalize();
|
|
vector17 *= scaleFactor2;
|
|
projectile.velocity = (projectile.velocity * 24f + vector17) / 25f;
|
|
projectile.velocity.Normalize();
|
|
projectile.velocity *= scaleFactor2;
|
|
}
|
|
|
|
if (projectile.velocity.Length() < 18f)
|
|
{
|
|
projectile.velocity *= 1.02f;
|
|
}
|
|
|
|
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
|
|
|
|
Lighting.AddLight(projectile.Center, 0f, 0.35f, 0.35f);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
if (projectile.timeLeft > 295)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
}
|
|
}
|