private void NewWave(int wave) { ClearMonsters(); Game1.getFarm().debris.Clear(); thisWave = waves[wave]; monstersDeployed = 0; spotIndex = 0; waveStarted = true; }
private void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.OneSecondUpdateTickedEventArgs e) { if (!Context.IsWorldReady || !Game1.player.IsMainPlayer || !(Game1.player.currentLocation is Farm) || thisWave == null) { return; } if (waveStarted) { if (Game1.getFarm().characters.Where(n => n is Monster).Count() >= Config.MaxSimultaneousMonsters) { if (waitingSeconds++ > 60) { ClearMonsters(); } return; } waitingSeconds = 0; if (thisWave.totalMonsters() <= 0) { thisWave = null; waveStarted = false; return; } Vector2[] spots = GetOpenSpots().ToArray(); spotIndex = 0; if (thisWave.slimes > 0) { Game1.getFarm().characters.Add(new GreenSlime(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.slimes--; } if (thisWave.bigSlimes > 0) { Game1.getFarm().characters.Add(new BigSlime(spots[spotIndex++] * Game1.tileSize, 40) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.bigSlimes--; } if (thisWave.bats > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.bats--; } if (thisWave.flies > 0) { Game1.getFarm().characters.Add(new Fly(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.flies--; } if (thisWave.dustSpirits > 0) { Game1.getFarm().characters.Add(new DustSpirit(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.dustSpirits--; } if (thisWave.shadowBrutes > 0) { Game1.getFarm().characters.Add(new ShadowBrute(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.shadowBrutes--; } if (thisWave.skeletons > 0) { Game1.getFarm().characters.Add(new Skeleton(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.skeletons--; } if (thisWave.shadowShamans > 0) { Game1.getFarm().characters.Add(new ShadowShaman(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.shadowShamans--; } if (thisWave.serpents > 0) { Game1.getFarm().characters.Add(new Serpent(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.serpents--; } if (thisWave.squidKids > 0) { Game1.getFarm().characters.Add(new SquidKid(spots[spotIndex++] * Game1.tileSize)); spotIndex %= spots.Length; thisWave.squidKids--; } if (thisWave.dinos > 0) { Game1.getFarm().characters.Add(new DinoMonster(spots[spotIndex++] * Game1.tileSize) { willDestroyObjectsUnderfoot = true }); spotIndex %= spots.Length; thisWave.dinos--; } if (thisWave.skulls > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize, 77377)); spotIndex %= spots.Length; thisWave.skulls--; } if (thisWave.dolls > 0) { Game1.getFarm().characters.Add(new Bat(spots[spotIndex++] * Game1.tileSize, -666)); spotIndex %= spots.Length; thisWave.dolls--; } } }