dofile("script\\gamemenu.lua");
dofile("script\\lib.lua");
set_inpun_fun("gameinput");

location={}
location["garage"] = true
location["garage"] = {}
location["garage"]["id"] = 14
location["garage"]["sub_id"] = 0
location["killer"] = true
location["killer"] = {}
location["killer"]["id"] = 14
location["killer"]["sub_id"] = 1
location["gym"] = true
location["gym"] = {}
location["gym"]["id"] = 14
location["gym"]["sub_id"] = 2

function LoadingLevel(param)
    SetAlfaValue(501,0)
	SetAlfaValue(503,0)
	SLevel=param;
return;end;

function LevelComplete()
	flags.levelcomplete=true;
	setcurentleaf("garage",14,0);
		DeleteElement("gr",213);
		DeleteElement("gr",219);
		DeleteElement("gr",224);
		DeleteElement("gr",225);
		DeleteElement("gr",226);
		DeleteElement("gr",227);
		DeleteElement("gr",232);
		DeleteElement("gr",223);
		DeleteElement("gr",208);
	setcurentleaf("killer",14,1);
		DeleteElement("gr",215);
		DeleteElement("gr",221);
		DeleteElement("gr",248);
		DeleteElement("gr",249);
		DeleteElement("gr",254);
	setcurentleaf("gym",14,2);	
		DeleteElement("gr",111);
	DarkScreen(true);
	ShowMenu(false);
end;
function StartLevel()
	setcurentleaf("garage",14,0);	
		if not flags.bolti then
			AddParticleToObject(27,"Vilka",0,0);
			StartEmiter("Vilka");
			MoveEmiter("Vilka",343,535);
		end;		
		if flags.bolti and not flags.minicomplete then
			AddParticleToObject(31,"Bike",519,582);
			StartEmiter("Bike");
			MoveEmiter("Bike",519,582);			
		end;
		if not flags.lock1 then
			AddParticleToObject(54,"Zamok",0,0);
			StartEmiter("Zamok");
			MoveEmiter("Zamok",984,358)	
		end;
	setcurentleaf("killer",14,1);	
		if not flags.wkatulka then
			AddParticleToObject(24,"Box",0,0);
			StartEmiter("Box");
			MoveEmiter("Box",100,496);	
		end;
		if flags.wkatulka and not flags.minicomplete1 then
			AddParticleToObject(67,"OpenBox",88,510);
			StartEmiter("OpenBox");
			MoveEmiter("OpenBox",82,510);			
		end;
		if not flags.bed then
			AddParticleToObject(52,"Bed",0,0);
			StartEmiter("Bed");
			MoveEmiter("Bed",472,562)	
		end;		
		if flags.bed and flags.lock then
			AddParticleToObject(55,"Zamok1",0,0);
			StartEmiter("Zamok1");
			MoveEmiter("Zamok1",631,576);			
		end;
		if not flags.minicomplete2 then 
			AddParticleToObject(45,"Tumb",0,0);
			StartEmiter("Tumb");
			MoveEmiter("Tumb",132,574)	
		end;	
		if not flags.hook then
			AddParticleToObject(51,"Hook",0,0);
			StartEmiter("Hook");
			MoveEmiter("Hook",519,64)		
		end;
		if flags.hook and not flags.open then
			AddParticleToObject(60,"Rope",0,0);
			StartEmiter("Rope");
			MoveEmiter("Rope",523,181);				
		end;
	setcurentleaf("gym",14,2);		
		if not flags.minicomplete3 then
			AddParticleToObject(13,"Gant",0,0);
			StartEmiter("Gant");
			MoveEmiter("Gant",801,553);	
		end;
end;


flags={};
flags["whole_darkness"]=false;
flags["loc1"]=false;
flags["loc2"]=false;
flags["loc3"]=false;
flags["firstloc2"]=true;
flags["firstloc3"]=true;
flags["minicompete"]=false;
flags["minicompete1"]=false;
flags["minicompete2"]=false;
flags["minicompete3"]=false;

flags["bolt1"]=false;
flags["bolt2"]=false;
flags["bolt3"]=false;
flags["bolt4"]=false;
flags["bolt5"]=false;
flags["bolti"]=false;
flags["bolti1"]=false
flags["wheel"]=false;
flags["bed"]=false;
flags["bedopen"]=false;
flags["newspaper"]=false;
flags["all"]=false;
flags["lock"]=true;
flags["lock1"]=false;
flags["open"]=false;
flags["bikeout"]=false;
flags["minitext1"]=false;
flags["levelcomplete"]=false;
flags["allobject1"]=false;
flags["HintCount"]=5;
flags["wkatulka"]=false;
flags["comics"]=false

add_tree_leaf("Root","garage",14,0);-- Добавляет лист в дерево 
SetCurrentRM("menu");
    addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
	AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);	
SetCurrentRM("main");
	loadresource("data\\photoaparat.png","photoaparat",112121212);
	AddImgToBook("photoaparat",838,580);
	AddHints()
ShowMenu(false);
dofile("./data/14/0/res.lua");

add_tree_leaf("Root","killer",14,1);
SetCurrentRM("menu");
	addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
	AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);
SetCurrentRM("main");
dofile("./data/14/1/res.lua");

add_tree_leaf("Root","gym",14,2);
SetCurrentRM("menu");
	addstaticobjecttogame(877777777,"menubuttons",63,622,"",60,0,61,61);
	AddSheet(1002,"re","red_b",63,622,61,61,"",128,640,650,115,15,5,7,7,0,59,877777777);
SetCurrentRM("main");
dofile("./data/14/2/res.lua");

setcurentleaf("garage",14,0);
SwitchToSheet("re");

DarkScreen(true);
speciale_action(2,503,true);
speciale_action(4,503)

playfile(".\\sound\\Music_2.ogg",true,true);