function InitCommon()
	SetToolCount(2,-1);
	SetToolCount(3,-1);
	SetToolCount(4,-1);
	SetToolCount(5,-1);
	SetToolCount(6,-1);
	SetToolCount(7,-1);
	SetToolCount(8,-1);
	SetToolCount(9,-2);
	BlockTile(3,13,true);
	BlockTile(5,13,true);
	BlockTile(5,11,true);
	BlockTile(5,9,true);
	BlockTile(4,8,true);
end

function OnInit()
	InitCommon();
	RequiresStop(0,true);
	AddTile("door0",8,3,13,1);
	AddTile("door1",8,5,13,1);
	AddTile("door2",8,5,11,1);
	AddTile("door3",8,5,9,1);
	AddTile("door4",8,4,8,1);
	AddAnimation("slideDown0",0,0,0,0,-0.8,0,3,false);
	AddAnimation("slideDown1",0,0,0,0,-0.8,0,3,false);
	AddAnimation("slideDown2",0,0,0,0,-0.8,0,3,false);
	AddAnimation("slideDown3",0,0,0,0,-0.8,0,3,false);
	AddAnimation("slideDown4",0,0,0,0,-0.8,0,3,false);
end

function OnReset()
	InitCommon();
end

function OnTrigger(trigger,robot)
	if (trigger==0) then
		EndGame(true);
	end

	if (trigger==1) then
		AnimateTile("door0","slideDown0");
		AnimateTile("door1","slideDown1");
	end

	if (trigger==2) then
		AnimateTile("door3","slideDown3");
		AnimateTile("door4","slideDown4");
	end

	if (trigger==3) then
		AnimateTile("door2","slideDown2");
	end
end

function OnAnimationDone(x,y)
	BlockTile(x,y,not IsBlocked(x,y));
end
