Files
CalamityModPublic/Projectiles/Boss/BrimstoneWave.cs
T

105 lines
3.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.NPCs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class BrimstoneWave : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
private int x;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 4;
}
public override void SetDefaults()
{
Projectile.width = 40;
Projectile.height = 30;
Projectile.hostile = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 1200;
Projectile.Opacity = 0f;
CooldownSlot = ImmunityCooldownID.Bosses;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(x);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
x = reader.ReadInt32();
}
public override void AI()
{
x++;
Projectile.velocity.Y = (float)(5D * Math.Sin(x / 5D));
Projectile.frameCounter++;
if (Projectile.frameCounter > 12)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 3)
Projectile.frame = 0;
if (Projectile.timeLeft < 30)
Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 30f, 0f, 1f);
else
Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - 1170) / 30f), 0f, 1f);
Lighting.AddLight(Projectile.Center, 0.5f * Projectile.Opacity, 0f, 0f);
if (Projectile.velocity.X < 0f)
Projectile.spriteDirection = 1;
else
Projectile.spriteDirection = -1;
}
public override bool PreDraw(ref Color lightColor)
{
SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
int num214 = texture.Height / Main.projFrames[Projectile.type];
int y6 = num214 * Projectile.frame;
lightColor.R = (byte)(255 * Projectile.Opacity);
if (CalamityGlobalNPC.SCal != -1)
{
if (Main.npc[CalamityGlobalNPC.SCal].active)
{
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().cirrus)
lightColor.B = (byte)(255 * Projectile.Opacity);
}
}
Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, num214 / 2f), Projectile.scale, spriteEffects, 0);
return false;
}
public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f;
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0 || Projectile.Opacity != 1f)
return;
target.AddBuff(ModContent.BuffType<VulnerabilityHex>(), 120, true);
}
}
}