package simogl.level;

import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;

import simogl.effect.light.Light;
import com.sun.opengl.util.texture.*;

public class DemoLevel extends AbstractLevel 
{
	private Light ambDiffLight = null;
	
	private Texture texWater = null;
	private Texture texTerrain = null;
	
	/**
	 * Creates a new level with the specified initial values for
	 * gold and food for the player
	 * @param gl
	 * @param amountGold initial amount of gold for the player
	 * @param amountFood initial amount of food for the player
	 */
	public DemoLevel(GL gl, int amountGold, int amountFood) 
	{
		super(gl,amountGold, amountFood);
	}

	@Override
	public void createTextures() 
	{
		try
		{
			this.texWater = TextureIO.newTexture(new File("./resources/textures/water/water0.jpg"),true);
			this.texTerrain = TextureIO.newTexture(new File("./resources/textures/terrain/ground_2048.jpg"),true);			
		}
		catch(IOException ioexcp)
		{
			System.err.println("Some texture data could not be loaded.");
			ioexcp.printStackTrace();
		}
	}

	@Override
	public void createWorldContent(GL gl)
	{
		Light.setGlobalAmbientLight(gl,0f,0f,0f,0f);
		this.ambDiffLight = new Light(30f,1024f,0f,0);
		this.ambDiffLight.setColorAmbient(1f,1f,1f,1f);
		this.ambDiffLight.setColorDiffuse(1f,1f,1f,1f);
		this.ambDiffLight.setEnabledAmbient(true);
		this.ambDiffLight.setEnabledDiffuse(true);
		//this.ambDiffLight.setEnabled(false);
		lights.add(this.ambDiffLight);
		
		String p = "./resources/textures/skybox/";
		this.createSkybox(gl,p+"north.bmp",p+"south.bmp",p+"east.bmp",p+"west.bmp",p+"top.bmp",p+"bottom.bmp");
		
		this.createTerrain(gl,"./resources/maps/map7_2048.raw",2048,32,this.texTerrain);
		terrain.showWireFrame(false);
		
		this.createWaterLayer(gl,2048,40f,this.texWater);
		
		this.createRain(2048,300);
	}
}
