public Level Generate()
    {
        Level          levelGen = new Level();
        LevelFromImage lfi      = new LevelFromImage();

        levelGen.structure = lfi.BuildStructure();
        lfi.AddObjectsFromImage(levelGen);

        if (lfi.output.playerSpawns <= 0)
        {
            levelGen.playerSpawnPoints = SetPlayerSpawnPoints(levelGen);
        }

        //levelGen.pickupSpawnPoints = SetPickupSpawnPoints();
        //levelGen.enemySpawnPoints = SetEnemySpawnPoints();

        pickUpCount = ((levelGen.structure.GetLength(0) * levelGen.structure.GetLength(1)) / 100);
        //int factor = ((levelGen.structure.GetLength(0) + levelGen.structure.GetLength(1) / 100));
        int factor = 1;

        pickUpCount = pickUpCount + (rng.Next(0, 10) * factor);

        enemyCount     = pickUpCount * 2;
        pickUpCount   += 10;
        maxMeleeCount  = enemyCount / 2;
        maxRangedCount = (enemyCount / 2) - 1;
        maxBossCount   = 1;
        /**/

        /*
         * for (int i = 0; i < enemyCount; i++)
         * {
         *  if (rng.Next(0, 2) == 0 && !(maxMeleeCount >= enemyCount / 2 + (rng.Next(-5, 5))) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxMeleeCount++;
         *  if (rng.Next(0, 2) == 1 && !(maxRangedCount >= enemyCount / 2 + (rng.Next(-5, 5))) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxRangedCount++;
         *  if (rng.Next(0, 2) == 2 && !(maxBossCount >= enemyCount/20) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxBossCount++;
         * }
         * /**/


        for (int i = 0; i < enemyCount; i++)
        {
            //int current = rng.Next(0, levelGen.enemySpawnPoints.Count);
            levelGen.enemies.Add(SpawnEnemy(levelGen));
            //levelGen.enemySpawnPoints.RemoveAt(current);
        }

        for (int i = 0; i < pickUpCount; i++)
        {
            //int current = rng.Next(0, levelGen.pickupSpawnPoints.Count);
            levelGen.pickUps.Add(SpawnPickup(levelGen, rng.Next(0, ItemLibrary.Get().generics.Count)));
            //levelGen.pickupSpawnPoints.RemoveAt(current);
        }
    public Level Generate()
    {
        Level levelGen = new Level();
        LevelFromImage lfi = new LevelFromImage();
        levelGen.structure = lfi.BuildStructure();
        lfi.AddObjectsFromImage(levelGen);

        if(lfi.output.playerSpawns <= 0)
        {
            levelGen.playerSpawnPoints = SetPlayerSpawnPoints(levelGen);
        }

        //levelGen.pickupSpawnPoints = SetPickupSpawnPoints();
        //levelGen.enemySpawnPoints = SetEnemySpawnPoints();

        pickUpCount = ((levelGen.structure.GetLength(0) * levelGen.structure.GetLength(1)) / 100);
        //int factor = ((levelGen.structure.GetLength(0) + levelGen.structure.GetLength(1) / 100));
        int factor = 1;
        pickUpCount = pickUpCount + (rng.Next(0, 10) * factor);

        enemyCount = pickUpCount * 2;
        pickUpCount += 10;
        maxMeleeCount = enemyCount / 2;
        maxRangedCount = (enemyCount / 2) - 1;
        maxBossCount = 1;
        /**/

        /*
        for (int i = 0; i < enemyCount; i++)
        {
            if (rng.Next(0, 2) == 0 && !(maxMeleeCount >= enemyCount / 2 + (rng.Next(-5, 5))) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxMeleeCount++;
            if (rng.Next(0, 2) == 1 && !(maxRangedCount >= enemyCount / 2 + (rng.Next(-5, 5))) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxRangedCount++;
            if (rng.Next(0, 2) == 2 && !(maxBossCount >= enemyCount/20) && !(maxMeleeCount + maxRangedCount + maxBossCount >= enemyCount)) maxBossCount++;
        }
        /**/

        for (int i = 0; i < enemyCount; i++)
        {
            //int current = rng.Next(0, levelGen.enemySpawnPoints.Count);
            levelGen.enemies.Add(SpawnEnemy(levelGen));
            //levelGen.enemySpawnPoints.RemoveAt(current);
        }

        for (int i = 0; i < pickUpCount; i++)
        {
            //int current = rng.Next(0, levelGen.pickupSpawnPoints.Count);
            levelGen.pickUps.Add(SpawnPickup(levelGen, rng.Next(0, ItemLibrary.Get().generics.Count)));
            //levelGen.pickupSpawnPoints.RemoveAt(current);
        }

        /**/
        //Debugging win field
        //levelGen.trigger.Add(new TriggerObject("endoflevel", new Vector2(0, 19)));

        return levelGen;
    }

    private Tile[,] BuildStructure()
    {
        Tile[,] levelGenStructure = new Tile[32, 32];

        for (int i = 0; i < levelGenStructure.GetLength(0); i++)
        {
            for (int j = 0; j < levelGenStructure.GetLength(1); j++)
            {
                levelGenStructure[i, j] = new Tile("floor", ClipType.FLOOR);
            }
        }

        return levelGenStructure;
    }

    private List<Vector2> SetEnemySpawnPoints()
    {
        List<Vector2> spawns = new List<Vector2>();

        spawns.Add(new Vector2(15, 3));
        spawns.Add(new Vector2(15, 6));
        spawns.Add(new Vector2(15, 9));

        return spawns;
    }

    private List<Vector2> SetPickupSpawnPoints()
    {
        List<Vector2> spawns = new List<Vector2>();

        /*
        spawns.Add(new Vector2(5, 5));
        spawns.Add(new Vector2(5, 15));
        spawns.Add(new Vector2(15, 5));
        spawns.Add(new Vector2(15, 15));
        spawns.Add(new Vector2(5, 10));
        spawns.Add(new Vector2(10, 5));
        spawns.Add(new Vector2(10, 10));
        /**/

        spawns.Add(new Vector2(18, 2));
        spawns.Add(new Vector2(18, 1));
        spawns.Add(new Vector2(19, 1));
        spawns.Add(new Vector2(19, 2));
        spawns.Add(new Vector2(17, 2));
        spawns.Add(new Vector2(18, 3));
        spawns.Add(new Vector2(17, 3));

        return spawns;
    }