public override void Initialize() { MaxEnemies = 0; KilledEnemies = 0; CometsRemaining = 0; StarjinxUI.Initialize(); }
private void SpawnComets() { int maxSmallComets = savedComets["Small"] == -2 ? 3 : savedComets["Small"] + 1; //Use cached values if respawning comets int maxMedComets = savedComets["Medium"] == -2 ? 2 : savedComets["Medium"] + 1; int maxLargeComets = savedComets["Large"] == -2 ? 1 : savedComets["Large"] + 1; const float MaxDist = 450; const float MinDist = 80; float FindDistance() { float maxComets = maxLargeComets + maxMedComets + maxSmallComets; return(MathHelper.Lerp(MaxDist, MinDist, comets.Count / maxComets)); } void SpawnComet(int type) { Vector2 spawnPos = npc.Center + Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * FindDistance(); int id = NPC.NewNPC((int)spawnPos.X, (int)spawnPos.Y, type, npc.whoAmI, npc.whoAmI, comets.Count * 2, 0, -1); Main.npc[id].Center = spawnPos; Main.npc[id].dontTakeDamage = true; if (Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, id); } if (comets.Count <= 0 && (savedComets["Small"] != -1 || savedComets["Medium"] != -1 || savedComets["Large"] != -1)) { //Kinda ugly but it makes sure the respawned comet is next up if (Main.npc[id].modNPC != null && Main.npc[id].modNPC is SmallComet comet) { comet.nextUp = true; } } comets.Add(id); npc.netUpdate = true; } for (int i = 0; i < maxSmallComets; i++) { SpawnComet(ModContent.NPCType <SmallComet>()); } for (int i = 0; i < maxMedComets; i++) { SpawnComet(ModContent.NPCType <MediumComet>()); } for (int i = 0; i < maxLargeComets; i++) { SpawnComet(ModContent.NPCType <LargeComet>()); } savedComets["Small"] = savedComets["Medium"] = savedComets["Large"] = -2; //clear out cache StarjinxUI.Initialize(); StarjinxEventWorld.SetComets(comets.Count); //Set comet amount for ui purposes StarjinxEventWorld.SetMaxEnemies(1); //Initialize max enemies as well, in case of potential edge cases }
public override void PostUpdate() => StarjinxUI.Update();