Files
CalamityModPublic/Projectiles/Enemy/PearlBurst.cs
T
DominicKarma42 55e89c9b98 Replaced (hopefully) every magic number with a constant
Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
2020-05-30 17:56:36 -04:00

86 lines
3.3 KiB
C#

using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Enemy
{
public class PearlBurst : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Pearl Burst");
Main.projFrames[projectile.type] = 4;
}
public override void SetDefaults()
{
projectile.width = 40;
projectile.height = 64;
projectile.hostile = true;
projectile.penetrate = -1;
projectile.alpha = 255;
projectile.timeLeft = 300;
projectile.ignoreWater = true;
projectile.tileCollide = false;
}
public override void AI()
{
Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.5f / 255f);
if (Main.rand.NextBool(5))
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 92, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.7f);
}
projectile.frameCounter++;
if (projectile.frameCounter > 3)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame > 3)
{
projectile.frame = 0;
}
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - 1.57f;
projectile.alpha -= 6;
projectile.ai[1] += 1f;
if (projectile.ai[1] <= 20f)
{
projectile.velocity.X *= 0.975f;
projectile.velocity.Y *= 0.975f;
}
else if (projectile.ai[1] > 20f && projectile.ai[1] <= 39f)
{
projectile.velocity.X *= 1.05f;
projectile.velocity.Y *= 1.05f;
}
else if (projectile.ai[1] == 40f)
{
projectile.ai[1] = 0f;
}
projectile.localAI[0] += 1f;
if (projectile.localAI[0] == 30f)
{
projectile.localAI[0] = 0f;
for (int l = 0; l < 12; l++)
{
Vector2 vector3 = Vector2.UnitX * (float)-(float)projectile.width / 2f;
vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f);
vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default);
int num9 = Dust.NewDust(projectile.Center, 0, 0, 92, 0f, 0f, 160, default, 1f);
Main.dust[num9].scale = 1.1f;
Main.dust[num9].noGravity = true;
Main.dust[num9].position = projectile.Center + vector3;
Main.dust[num9].velocity = projectile.velocity * 0.1f;
Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f;
}
}
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(255, 255, 255);
}
}
}