#ifndef AREA_H
#define AREA_H



//#include "AstarPathfinder.h"
#include "ClientDatabase.h"

#define numlayers		1

class Area
{
private:
//need to make and area class that chang world to ares
	
string areaname;



	public:

		///need a unit list so we can draw and do conlistion on
	//	Unitlist units_in_area;
		int numberofUnits;
		string filename;
		string filename2;
Layer layers;

//UnitList units_in_area;
//CharacterList players;
 Area();
void redraw(View view,TileAnimeList,UnitList,DATAFILE * );
void load();
void reload(string);
//void edit(View);
//Layer *get_layers();

};
//end of Area

Area::Area()
{
filename2= "Units.txt"; //defalse
filename = "area1.txt";//defalse
numberofUnits = 0;

	//need this to be lodded from text file
/*
areaname = "wastland";
layers.set_filename("map1.dat");
layers[1].set_filename("map2.dat");
layers[2].set_filename("map3.dat");
layers[3].set_filename("map4.dat");
layers.set_masked(false);
layers[1].set_masked(true);
layers[2].set_masked(true);
layers[3].set_masked(true);
layers.load_layer();
layers[1].load_layer();
layers[2].load_layer();
layers[3].load_layer();
layers.layer_num=1;
layers[1].layer_num=2;
layers[2].layer_num=3;
layers[3].layer_num=4;
*/

//Sleep(10000);
}

void Area::load()
{

	ifstream inData;
	inData.open(filename.c_str());
	
	//char trash ;
	string num="";
	int num2 = 0;
			 

	inData >> num;

areaname = num;
	inData >> num;
layers.set_filename(num);
//	inData >> num;
//layers[1].set_filename(num);
//	inData >> num;
//layers[2].set_filename(num);
//	inData >> num;
//layers[3].set_filename(num);
	inData >> num;
filename2 = num;

	inData >> num2;
//numberofUnits = num2;
	
	inData.close();
	

//numberofUnits = 4;
	//need this to be lodded from text file

layers.set_masked(true);
//layers[1].set_masked(true);
//layers[2].set_masked(true);
//layers[3].set_masked(true);

layers.load_layer2();

//layers[1].load_layer();
//layers[2].load_layer();
//layers[3].load_layer();
layers.layer_num=1;
//layers[1].layer_num=2;
///layers[2].layer_num=3;
//layers[3].layer_num=4;

//numberofUnits = 4;
//filename2= "Units.txt";
/*
if (computerId== 0)
{

	if(numberofUnits >0)
	{
		Units.load(filename2); //load Units	
	}

}
*/
}
void Area::reload(string nf)
	{
		filename = nf;
		
		load();
	}

void Area::redraw(View view,TileAnimeList animations,UnitList unitL1,DATAFILE *data)
{

	/*
	for( int i=0;i<numlayers;i++)
	{
		layers[i].update_layer(view);
		Units.draw(layers[i].get_layerBitmap(),i+1,view);
		players.draw(layers[i].get_layerBitmap(),i+1,view);
		layers[i].draw_layer(view);
	}
	*/




	if(mapconter==maptimer)//limt map drawing
	{
if(graphic != false)
	{
layers.update_layer(view,animations,1,data);
}
	}
//layers[1].update_layer(view,animations);
//layers[2].update_layer(view,animations);
//layers[3].update_layer(view,animations);




unitL1.draw(layers.get_layerBitmap(),1,view,data,&layers);

if(mapconter==maptimer)//limt map drawing
	{
if(graphic != false)
	{
layers.update_layer(view,animations,2,data);
}
}
unitL1.draw(layers.get_layerBitmap(),2,view,data,&layers);//////////////////////////////////glitch
if(mapconter==maptimer)//limt map drawing
	{
if(graphic != false)
	{
layers.update_layer(view,animations,3,data);
}
}
unitL1.draw(layers.get_layerBitmap(),3,view,data,&layers);
if(mapconter==maptimer)//limt map drawing
	{
if(graphic != false)
	{
layers.update_layer(view,animations,4,data);
}
mapconter=0;
}
mapconter++;
unitL1.draw(layers.get_layerBitmap(),4,view,data,&layers);


//Units.draw(layers[1].get_layerBitmap(),2,view);
//Units.draw(layers[2].get_layerBitmap(),3,view);
//Units.draw(layers[3].get_layerBitmap(),4,view);
//players.draw(layers.get_layerBitmap(),1,view);
//players.draw(layers[1].get_layerBitmap(),2,view);
//players.draw(layers[2].get_layerBitmap(),3,view);
//players.draw(layers[3].get_layerBitmap(),4,view);

layers.draw_layer(view);
//layers[1].draw_layer(view);
//layers[2].draw_layer(view);
//layers[3].draw_layer(view);


}

#endif