// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
// 
//     private Gson gson = new GsonBuilder().setPrettyPrinting().create();
//     private List<Level> levels = new ArrayList<>();
// 
//     private LevelManager() {
//         load();
//     }
// 
//     public List<Level> getLevels() {
//         if (levels.size() == 0) {
//             Vector2 spawn = new Vector2(1.5f, 9.5f);
//             Vector2 goal = new Vector2(39.5f, 5.5f);
//             Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
//                     .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .build();
//             List<Wave> waves = new ArrayList<>();
//             waves.add(wave);
// 
//             levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
// 
//             levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
// 
//             //DEBUG DEBUG
//             try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
//                 gson.toJson(levels.get(0), writer);
//             } catch (IOException ex) {
//             }
//             try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
//                 gson.toJson(levels.get(1), writer);
//             } catch (IOException ex) {
//             }
// 
//             load();
//         }
//         return levels;
//     }
// 
//     public void load() {
//         levels = Arrays.stream(Gdx.files.internal("maps").list())
//                 .filter(f -> f.extension().equalsIgnoreCase("json"))
//                 .map(f -> gson.fromJson(f.reader(), Level.class))
//                 .filter(Objects::nonNull)
//                 .collect(Collectors.toList());
// 
//         Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
//     }
// 
//     private static LevelManager instance = new LevelManager();
// 
//     public static LevelManager getInstance() {
//         return instance;
//     }
// }


import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import me.minidigger.projecttd.level.LevelManager;
package me.minidigger.projecttd.screens;


/**
 * Created by Martin on 29/04/2017.
 */
public class MainMenuScreen implements Screen {

    private Stage stage;

    @Override
    public void show() {
        stage = new Stage();
        Gdx.input.setInputProcessor(stage);

        VisUI.load();

        VisTable table = new VisTable(true);

        VisTextButton newGameButton = new VisTextButton("New game");
        newGameButton.setBounds((Gdx.graphics.getWidth() / 2f) - 100, (Gdx.graphics.getHeight() / 2f) + 100, 200, 50);
        //   newGameButton.setPosition(Gdx.graphics.getWidth() / 2 - Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 2);
        newGameButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                GameScreen gameScreen = new GameScreen();
// Path: core/src/me/minidigger/projecttd/level/LevelManager.java
// public class LevelManager {
// 
//     private Gson gson = new GsonBuilder().setPrettyPrinting().create();
//     private List<Level> levels = new ArrayList<>();
// 
//     private LevelManager() {
//         load();
//     }
// 
//     public List<Level> getLevels() {
//         if (levels.size() == 0) {
//             Vector2 spawn = new Vector2(1.5f, 9.5f);
//             Vector2 goal = new Vector2(39.5f, 5.5f);
//             Wave wave = new WaveBuilder().waveType(WaveType.NORMAL).name("Wave 1").points(100).money(10)
//                     .group().delay(5).interval(1).health(100).speed(6).type(Minion.MinionType.LAND).count(10).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .group().delay(20).interval(2).health(300).speed(4).type(Minion.MinionType.LAND).count(5).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .group().delay(30).interval(1).health(1000).speed(2).type(Minion.MinionType.LAND).count(1).sprite(Minion.SPRITE).spawn(spawn).goal(goal).finish()
//                     .build();
//             List<Wave> waves = new ArrayList<>();
//             waves.add(wave);
// 
//             levels.add(new Level("Map 1", "map01.tmx", "MiniDigger", "badlogic.jpg", waves));
// 
//             levels.add(new Level("Map 2", "map02.tmx", "MiniDigger", "badlogic.jpg", waves));
// 
//             //DEBUG DEBUG
//             try (Writer writer = Gdx.files.absolute("maps/map01.json").writer(false)) {
//                 gson.toJson(levels.get(0), writer);
//             } catch (IOException ex) {
//             }
//             try (Writer writer = Gdx.files.absolute("maps/map02.json").writer(false)) {
//                 gson.toJson(levels.get(1), writer);
//             } catch (IOException ex) {
//             }
// 
//             load();
//         }
//         return levels;
//     }
// 
//     public void load() {
//         levels = Arrays.stream(Gdx.files.internal("maps").list())
//                 .filter(f -> f.extension().equalsIgnoreCase("json"))
//                 .map(f -> gson.fromJson(f.reader(), Level.class))
//                 .filter(Objects::nonNull)
//                 .collect(Collectors.toList());
// 
//         Gdx.app.log("DEBUG", "Loaded " + levels.size() + " levels");
//     }
// 
//     private static LevelManager instance = new LevelManager();
// 
//     public static LevelManager getInstance() {
//         return instance;
//     }
// }


// Path: core/src/me/minidigger/projecttd/screens/MainMenuScreen.java
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import me.minidigger.projecttd.level.LevelManager;

package me.minidigger.projecttd.screens;


/**
 * Created by Martin on 29/04/2017.
 */
public class MainMenuScreen implements Screen {

    private Stage stage;

    @Override
    public void show() {
        stage = new Stage();
        Gdx.input.setInputProcessor(stage);

        VisUI.load();

        VisTable table = new VisTable(true);

        VisTextButton newGameButton = new VisTextButton("New game");
        newGameButton.setBounds((Gdx.graphics.getWidth() / 2f) - 100, (Gdx.graphics.getHeight() / 2f) + 100, 200, 50);
        //   newGameButton.setPosition(Gdx.graphics.getWidth() / 2 - Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 2);
        newGameButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                GameScreen gameScreen = new GameScreen();
                gameScreen.level = LevelManager.getInstance().getLevels().get(0);