110 lines
3.9 KiB
C#
110 lines
3.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using CalamityMod.Buffs.DamageOverTime;
|
|
using CalamityMod.NPCs;
|
|
using CalamityMod.NPCs.SupremeCalamitas;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
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()
|
|
{
|
|
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 60 : 114);
|
|
dust.noGravity = true;
|
|
dust.velocity = Projectile.velocity * Main.rand.NextFloat(0.1f, 0.7f);
|
|
dust.scale = Main.rand.NextFloat(0.9f, 1.8f);
|
|
|
|
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 = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
|
|
int framing = texture.Height / Main.projFrames[Projectile.type];
|
|
int y6 = framing * 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, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 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);
|
|
}
|
|
}
|
|
}
|