dofile("script/layouts/room3_defaults.lua")
dofile("script/shifts/shift3_1_animations.lua")

--levelDesc.shiftcontrollers = { {objects={"pencil_table", "EVENT_EMPTY_TABLE"}} }
--table.copy_into(levelDesc.controllers,levelDesc.shiftcontrollers)

levelDesc.name = "Shift 3.1"
levelDesc.levelId = 31
levelDesc.musicMood = "3"
levelDesc.trigger =
{
	class = "TriggerSystem",
	triggers =
	{
		{ trigger = "spawn", delay=1, hearts=3, patient="p5", diseaseDesc = { class="Disease", steps={"TOILET", "BANDAID",} } },
		{ trigger = "spawn", delay=5000, hearts=2, patient="p2", diseaseDesc = { class="Disease", steps={"TOILET", "SPATULA",} } },
		{ trigger = "spawn", delay=8000, hearts=1, diseaseDesc = { class="Disease", steps={"GIVE_INJECTION", "SPATULA",} } },
		{ trigger = "spawn", delay=20000, hearts=2, patient="p3", diseaseDesc = { class="Disease", steps={"TOILET", "BANDAID", "SPATULA"} } },
		{ trigger = "startEvent", delay = 4000, },
		{ trigger = "spawn", delay=8000, hearts=1, diseaseDesc = { class="Disease", steps={"GIVE_INJECTION", "SPATULA"} } },
		{ trigger = "spawn", delay=25000, hearts=2, patient="p1", diseaseDesc = { class="Disease", steps={"TOILET", "GIVE_INJECTION"} } },
		{ trigger = "spawn", delay=1000, hearts=2, patient="p4", diseaseDesc = { class="Disease", steps={"TOILET", "BANDAID"} } },
		{ trigger = "spawn", delay=15000, hearts=3, diseaseDesc = { class="Disease", steps={"SPATULA"} } },
		{ trigger = "spawn", delay=13000, hearts=1, diseaseDesc = { class="Disease", steps={"GIVE_INJECTION", "SPATULA",} } },
		{ trigger = "spawn", delay=10000, patient="p0", hearts=2, diseaseDesc = { class="Disease", steps={"TOILET", "GIVE_INJECTION",} } },
		{ trigger = "spawn", delay=25000, hearts=3, diseaseDesc = { class="Disease", steps={"TOILET", "BANDAID", } } },
		{ trigger = "spawn", delay=6000, hearts=1, diseaseDesc = { class="Disease", steps={"GIVE_INJECTION", "SPATULA",} } },
		{ trigger = "spawn", delay=20000, patient="p2", hearts=2, diseaseDesc = { class="Disease", steps={"TOILET", "BANDAID",} } },
		{ trigger = "spawn", delay=8000, hearts=1, patient="p3", diseaseDesc = { class="Disease", steps={"TOILET", "GIVE_INJECTION", "SPATULA",} } },
	}
}
levelDesc.patientList =
{
	p0 = { weight = 500,
		base = "boy",
	},
	p1 = { weight = 500,
		base = "boy2",
	},
	p2 = { weight = 500,
		base = "boy3",
	},
	p3 = { weight = 500,
		base = "girl",
	},
	p4 = { weight = 500,
		base = "girl2",
	},
	p5 = { weight = 500,
		base = "girl3",
	},
}

function onObjectFound(event, obj)
	-- Move robotpiece to table
	local table = level:getObject("EVENT_EMPTY_TABLE")
	local pos_x, pos_y = 0,0
	repeat
		pos_x = math.Random(40,140)
		pos_y = math.Random(485,550)
	until(table:isInside(pos_x, pos_y) == true)

	obj.floor = 100
	obj:animate({x = pos_x, y = pos_y, style="easeInOut", duration = 500})
end

levelDesc.eventDesc =
{
	class="HiddenObjectEvent",
	eventBarImage = "EVENTBAR_ICON_R3_S1:icons",
	funcFound = onObjectFound,
	hideAllObjects = true,
	scoreOneDone = 1,
	scoreAllDone = 1,
	eventBarText = "TEXT_EVENT_TOY",
	hintArrowObjectId = "EVENT_HIDDENOBJECT_ROBOTPART_4",
}

function levelDesc:onShiftStartEnd()
	level:getObject("EVENT_EMPTY_TABLE").drawOutline = false
end

function levelDesc:onShiftFinish()
	hintManager:removeArrows({id="Hidden object event"})
    CareLevel.onShiftFinish(self)  
    
end
