public void EnemySpawn(int enemyCount) { while (this.worldObjects.Count < enemyCount) { int minPower = Rnd.Next(75); int maxPower = Rnd.Next(minPower, 101); // Currently has 5% chance to spawn enemy with bonus stuff. bool hasBonus = Rnd.Next(1, 101) < 5; var enemy = EnemyFactory.SpawnEnemy(minPower, maxPower, hasBonus); int positionX = Rnd.Next(0, (Camera.CameraMaxWidth + Game1.BufferWidth) - enemy.Animation.FrameWidth); int positionY = Rnd.Next(0, (Camera.CameraMaxHeight + Game1.BufferHeight) - enemy.Animation.FrameHeight); if (!CollisionHandler.CheckForEnemySpawnCollision(positionX, positionY)) { enemy.Position = new Vector2(positionX, positionY); this.worldObjects.Add(enemy); this.engine = Engine.GetInstance; } } }