Files
CalamityModPublic/Projectiles/Rogue/HypothermiaShard.cs
T

98 lines
3.8 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class HypothermiaShard : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
private float counter = 0f;
public override void SetDefaults()
{
Projectile.width = 6;
Projectile.height = 6;
Projectile.scale = 1f;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.alpha = 50;
Projectile.penetrate = 1;
Projectile.timeLeft = 600;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.extraUpdates = 3;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.1f, 0f, 0.5f);
Projectile.rotation += Projectile.velocity.X * 0.2f;
counter += 0.25f;
if (Main.rand.NextBool(10))
{
int num300 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 191, 0f, 0f, 0, default, 0.8f);
Main.dust[num300].noGravity = true;
Main.dust[num300].velocity *= 0.2f;
}
Projectile.velocity *= 0.996f;
if (counter > 100f)
{
Projectile.scale -= 0.05f;
if ((double)Projectile.scale <= 0.2)
{
Projectile.scale = 0.2f;
Projectile.Kill();
}
Projectile.width = (int)(6f * Projectile.scale);
Projectile.height = (int)(6f * Projectile.scale);
}
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
if (Projectile.velocity.X != oldVelocity.X)
{
Projectile.velocity.X = -oldVelocity.X;
}
if (Projectile.velocity.Y != oldVelocity.Y)
{
Projectile.velocity.Y = -oldVelocity.Y;
}
return false;
}
public override void Kill(int timeLeft)
{
for (int k = 0; k < 3; k++)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 191, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f);
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn, 120);
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Frostburn, 120);
public override bool PreDraw(ref Color lightColor)
{
//Changes the texture of the projectile
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
if (Projectile.ai[0] == 1f)
{
texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Rogue/HypothermiaShard2").Value;
}
if (Projectile.ai[0] == 2f)
{
texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Rogue/HypothermiaShard3").Value;
}
if (Projectile.ai[0] == 3f)
{
texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Rogue/HypothermiaShard4").Value;
}
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, 0);
return false;
}
}
}