Files
CalamityModPublic/Projectiles/Boss/SkyFlareRevenge.cs
T

86 lines
3.6 KiB
C#

using CalamityMod.NPCs.Yharon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Boss
{
public class SkyFlareRevenge : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public override string Texture => "CalamityMod/Projectiles/Boss/SkyFlare";
public static readonly SoundStyle FlareSound = new("CalamityMod/Sounds/Custom/Yharon/YharonInfernado");
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 5;
}
public override void SetDefaults()
{
Projectile.width = 30;
Projectile.height = 30;
Projectile.hostile = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 10;
CooldownSlot = ImmunityCooldownID.Bosses;
}
public override void AI()
{
Projectile.frameCounter++;
if (Projectile.frameCounter > 5)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 4)
{
Projectile.frame = 0;
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture2D13 = ModContent.Request<Texture2D>(Texture).Value;
int num214 = ModContent.Request<Texture2D>(Texture).Value.Height / Main.projFrames[Projectile.type];
int y6 = num214 * Projectile.frame;
Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(255, Main.DiscoG, 53, Projectile.alpha);
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(FlareSound, Projectile.Center);
int dustAmt = 36;
for (int d = 0; d < dustAmt; d++)
{
Vector2 dustSource = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f;
dustSource = dustSource.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center;
Vector2 dustVel = dustSource - Projectile.Center;
int idx = Dust.NewDust(dustSource + dustVel, 0, 0, 244, dustVel.X * 2f, dustVel.Y * 2f, 100, default, 1.4f);
Main.dust[idx].noGravity = true;
Main.dust[idx].noLight = true;
Main.dust[idx].velocity = dustVel;
}
if (Projectile.owner == Main.myPlayer)
{
int type = ModContent.ProjectileType<InfernadoRevenge>();
int damage = Projectile.GetProjectileDamage(ModContent.NPCType<Yharon>());
int nado = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, type, damage, 4f, Main.myPlayer, 16f, 50f);
Main.projectile[nado].Bottom = Projectile.Center;
Main.projectile[nado].netUpdate = true;
}
}
}
}