private static void LastStand() { var waveSize = (int)(sResources / SpawnPrice) + sAvailableSpawns; sAvailableSpawns = 0; var finalWave = new List <Zombie>(); var spawnBox = (int)Math.Sqrt(waveSize); for (var i = 0; i < waveSize; i++) { var position = new Vector2(sRandom.Next((int)sAiBasePosition.X - spawnBox / 2, (int)sAiBasePosition.X + spawnBox / 2), sRandom.Next((int)sAiBasePosition.Y - spawnBox / 2, (int)sAiBasePosition.Y + spawnBox / 2)); while (Game1.sTileMap.GetTileType((int)position.X, (int)position.Y) == Tile.Water || ObjectManager.Instance.CheckTile(position, typeof(IPathCollidable)).Any(obj => !(obj is Graveyard))) { position = new Vector2(sRandom.Next((int)sAiBasePosition.X - spawnBox / 2, (int)sAiBasePosition.X + spawnBox / 2), sRandom.Next((int)sAiBasePosition.Y - spawnBox / 2, (int)sAiBasePosition.Y + spawnBox / 2)); } var zombie = new Zombie(position.X, position.Y); finalWave.Add(zombie); ObjectManager.Instance.Add(zombie); zombie.Charge(ObjectManager.Instance.GetFarmer().Position); zombie.PreferredTargetType = typeof(Farmer); } sWaves.Add(finalWave); }