public void rendermap(MapElement tocreate) {

		map.clearTiles();
		UE = new ArrayList<UnitElement>();
		UE = (ArrayList<UnitElement>) tocreate.getunitlist();
		EE = new ArrayList<EnvironmentElement>();
		EE = (ArrayList<EnvironmentElement>) tocreate.getEnviromentList();

		pixelsX = tocreate.getpixelsX();
		pixelsY = tocreate.getpixelsY();
		tilesX = tocreate.gettilesX();
		tilesY = tocreate.gettilesY();
		level = tocreate.getLevel();
		currState = tocreate.getState();

		for(UnitElement U:UE) {
			Unit unit = U.getUnit();
			UnitOwner owner = U.getUnitOwner();

			int x = unit.getXTileLoc();
			int y = unit.getYTileLoc();

			try {
				Unit toset = unit.getClass().newInstance();
				map.getTileByCoords(x, y).setUnit(toset);
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}

		for(EnvironmentElement E:EE) {
			ArrayList<Environment> EArray = E.getEnviroment();
			int x = E.getX();
			int y = E.getY();

			for(Environment EA: EArray) {
				try {

					Class myObjectClass = EA.getClass();
					String myObjName = myObjectClass.getSimpleName();
				
					//double size = TBGame.EnviromentSizeMap.get(myObjName);
					//
					//Constructor<Environment> ctor = myObjectClass.getConstructor(double.class);
					//Environment instance = ctor.newInstance(size); 
					//map.getTileByCoords(x, y).setEnvironment(instance);

					if(myObjName.equals("Mountain")) {
						map.getTileByCoords(x, y).setEnvironment(new Mountain(1));
					}else if(myObjName.equals("PoisonGas")) {
						map.getTileByCoords(x, y).setEnvironment(new PoisonGas(1, 0, 1000));
					}else if(myObjName.equals("Snow")) {
						map.getTileByCoords(x, y).setEnvironment(new Snow(0.3, 0, 1000));
					}

				} catch (Exception e) {
					e.printStackTrace();
				} 
			}	
		}
	}