diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 1252589ba0..809a8bbe55 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -323,18 +323,22 @@ namespace CalamityMod.Events [NPCID.TheDestroyer] = npc => { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierOneEndText", XerocTextColor); + CreateTierAnimation(2); }, [NPCID.CultistBoss] = npc => { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierTwoEndText", XerocTextColor); + CreateTierAnimation(3); }, [NPCID.DukeFishron] = npc => { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierThreeEndText", XerocTextColor); + CreateTierAnimation(4); }, [ModContent.NPCType()] = npc => { CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierFourEndText", XerocTextColor); + CreateTierAnimation(5); }, [ModContent.NPCType()] = npc => { @@ -609,6 +613,22 @@ namespace CalamityMod.Events BossRushSky.CurrentInterest = 0.85f; } + + public static void CreateTierAnimation(int tier) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + int animation = Projectile.NewProjectile(new EntitySource_WorldEvent(), Main.player[i].Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, i); + if (Main.projectile.IndexInRange(animation)) + Main.projectile[animation].ai[0] = tier; + } + } + } #endregion #region Netcode diff --git a/Projectiles/Typeless/BossRushTier2Animation.png b/Projectiles/Typeless/BossRushTier2Animation.png new file mode 100644 index 0000000000..93fb86bb54 Binary files /dev/null and b/Projectiles/Typeless/BossRushTier2Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier3Animation.png b/Projectiles/Typeless/BossRushTier3Animation.png new file mode 100644 index 0000000000..5a3205be0f Binary files /dev/null and b/Projectiles/Typeless/BossRushTier3Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier4Animation.png b/Projectiles/Typeless/BossRushTier4Animation.png new file mode 100644 index 0000000000..fc2e379198 Binary files /dev/null and b/Projectiles/Typeless/BossRushTier4Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier5Animation.png b/Projectiles/Typeless/BossRushTier5Animation.png new file mode 100644 index 0000000000..60fb8d4ba2 Binary files /dev/null and b/Projectiles/Typeless/BossRushTier5Animation.png differ diff --git a/Projectiles/Typeless/BossRushTierAnimation.cs b/Projectiles/Typeless/BossRushTierAnimation.cs new file mode 100644 index 0000000000..94a3e49fed --- /dev/null +++ b/Projectiles/Typeless/BossRushTierAnimation.cs @@ -0,0 +1,51 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BossRushTierAnimation : ModProjectile + { + public int Tier => (int)Projectile.ai[0]; + + public Player Owner => Main.player[Projectile.owner]; + + public const int FrameChangeRate = 4; + + public const int TotalFrames = 56; + + public override string Texture => "CalamityMod/Projectiles/Typeless/BossRushTier2Animation"; + + public override void SetDefaults() + { + Projectile.width = 76; + Projectile.height = 180; + Projectile.aiStyle = -1; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.timeLeft = FrameChangeRate * TotalFrames; + Projectile.penetrate = -1; + } + + public override void AI() + { + Projectile.Bottom = Owner.Top - Vector2.UnitY * Projectile.scale * 36f; + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / FrameChangeRate; + if (Projectile.frame >= TotalFrames) + Projectile.frame = TotalFrames; + } + + public override Color? GetAlpha(Color lightColor) => Color.White * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request($"CalamityMod/Projectiles/Typeless/BossRushTier{Tier}Animation").Value; + Rectangle frame = texture.Frame(14, 4, Projectile.frame % 14, Projectile.frame / 14); + Vector2 origin = frame.Size() * 0.5f; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), 0f, origin, Projectile.scale, 0, 0f); + return false; + } + } +}