package uk.co.beercave.gunboat;

import uk.co.beercave.gunboat.entities.GameWorld;
import uk.co.beercave.gunboat.renderers.FaderRenderer;
import uk.co.beercave.gunboat.renderers.GuiRenderer;
import uk.co.beercave.gunboat.renderers.SeaRenderer;
import uk.co.beercave.gunboat.renderers.SkyRenderer;
import uk.co.beercave.gunboat.screens.GameScreen;
import uk.co.beercave.gunboat.screens.TitleScreen;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class GunBoat extends Game implements ApplicationListener {
	private OrthographicCamera camera;
	private SpriteBatch batch;
	
	private GameScreen game;
	private TitleScreen title;
	
	@Override
	public void create() {		
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		
		camera = new OrthographicCamera(800, 480);
		camera.translate(400, 240);
		camera.update();
		batch = new SpriteBatch();

		ResourceManager.initialise();
		SkyRenderer.initialise(camera, batch);
		
		FaderRenderer.initialise(camera, batch);
		GuiRenderer.initialise(camera, batch);
		SeaRenderer.initialise(camera, batch);
		
		
		GameWorld.initialise();
		
		game = new GameScreen(this);
		title = new TitleScreen(this);
		
		setScreen(title);
		
	}
	public enum ScreenType{
		GAME,
		TITLE
	}
	public void switchScreen(ScreenType screen){
		Gdx.app.log("", "Switching to screen " + screen.toString());
		switch (screen) {
		case GAME:
			setScreen(game);
			break;
		case TITLE:
		setScreen(title);
			break;
		}
	}
	

	@Override
	public void dispose() {
		batch.dispose();
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}


	public void addController(GameController controller) {
		ControlSystems.controllers.add(controller);
		if (ControlSystems.current == null) ControlSystems.current = controller;
		
	}
}
