Files
CalamityModPublic/Projectiles/Magic/IceBlockIcicle.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

66 lines
2.5 KiB
C#

using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Projectiles.Magic
{
public class IceBlockIcicle : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ice Barrage");
}
public override void SetDefaults()
{
projectile.width = 18;
projectile.height = 18;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.magic = true;
projectile.timeLeft = 600;
projectile.coldDamage = true;
}
public override void AI()
{
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + (MathHelper.Pi * 0.5f * projectile.direction);
projectile.velocity.Y += 0.25f;
if(projectile.velocity.Y > 16f)
{
projectile.velocity.Y = 16f;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.ai[0] == 1f)
{
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/IceBlockIcicle2");
Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f);
return false;
}
return true;
}
public override void Kill(int timeLeft)
{
for (int i = 0; i < 20; i++)
{
int dustType = Main.rand.NextBool(2) ? 68 : 67;
if (Main.rand.NextBool(4))
{
dustType = 80;
}
Vector2 direction = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, 4f));
int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, direction.X, direction.Y, 50, default, 1.1f);
Main.dust[dust].noGravity = true;
}
Main.PlaySound(SoundID.NPCHit5, projectile.Center);
}
}
}