108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class IceBlast : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Ice Blast");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 10;
|
|
Projectile.height = 10;
|
|
Projectile.penetrate = -1;
|
|
Projectile.hostile = true;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight((int)((Projectile.position.X + (Projectile.width / 2)) / 16f), (int)((Projectile.position.Y + (Projectile.height / 2)) / 16f), 0f, 0.25f, 0.25f);
|
|
|
|
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2;
|
|
|
|
for (int num322 = 0; num322 < 2; num322++)
|
|
{
|
|
int num323 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, Projectile.velocity.X, Projectile.velocity.Y, 50, default, 0.6f);
|
|
Main.dust[num323].noGravity = true;
|
|
Dust dust = Main.dust[num323];
|
|
dust.velocity *= 0.3f;
|
|
}
|
|
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
Projectile.scale += 0.01f;
|
|
Projectile.alpha -= 50;
|
|
if (Projectile.alpha <= 0)
|
|
{
|
|
Projectile.localAI[0] = 1f;
|
|
Projectile.alpha = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Projectile.scale -= 0.01f;
|
|
Projectile.alpha += 50;
|
|
if (Projectile.alpha >= 255)
|
|
{
|
|
Projectile.localAI[0] = 0f;
|
|
Projectile.alpha = 255;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return Main.dayTime ? new Color(50, 50, 255, Projectile.alpha) : new Color(255, 255, 255, Projectile.alpha);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
int num497 = 5;
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
|
|
int num3;
|
|
for (int num498 = 0; num498 < num497; num498 = num3 + 1)
|
|
{
|
|
int num499 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 92, 0f, 0f, 0, default, 1f);
|
|
if (Main.rand.Next(3) != 0)
|
|
{
|
|
Dust dust = Main.dust[num499];
|
|
dust.velocity *= 2f;
|
|
Main.dust[num499].noGravity = true;
|
|
dust = Main.dust[num499];
|
|
dust.scale *= 1.75f;
|
|
}
|
|
else
|
|
{
|
|
Dust dust = Main.dust[num499];
|
|
dust.scale *= 0.5f;
|
|
}
|
|
num3 = num498;
|
|
}
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, int damage, bool crit)
|
|
{
|
|
target.AddBuff(BuffID.Frostburn, 90, true);
|
|
target.AddBuff(BuffID.Chilled, 60, true);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
|
|
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
|
|
return false;
|
|
}
|
|
}
|
|
}
|