package pathgame;

import me.hammerle.snuviengine.api.IGame;
import me.hammerle.snuviengine.api.Renderer;
import pathgame.gameplay.Gamestate;
import pathgame.gameplay.Gamestates;
import pathgame.gameplay.Keys;
import pathgame.gameplay.Level;
import pathgame.gameplay.menu.Menu;
import pathgame.rendering.LevelRenderer;
import pathgame.rendering.MenuRenderer;

public class PathGame implements IGame
{
    private final Gamestate gamestate = new Gamestate();

    private final Level level = new Level();
    private final LevelRenderer levelRenderer = new LevelRenderer();
    
    private final Menu menu = new Menu();
    private final MenuRenderer menuRenderer = new MenuRenderer();

    public PathGame()
    {
    }

    @Override
    public void tick()
    {
        level.tick(gamestate);
        levelRenderer.tick(level, gamestate);
        
        menu.tick(gamestate, level);
        
        if(Keys.TEST_KEY.getTime() == 1)
        {
            //level.nextLevel();
            level.getPlayer().win(level.getMap());
        }
    }

    @Override
    public void renderTick(Renderer r, float lag)
    {
        if(gamestate.is(Gamestates.MENU))
        {
            levelRenderer.renderTick(r, 0.0f, level, gamestate);
            menuRenderer.renderTick(r, 0.0f, menu);
        }
        else
        {
            levelRenderer.renderTick(r, lag, level, gamestate);
        }
    }

    @Override
    public void onStop()
    {
    }
}