dofile("script/layouts/room4_defaults.lua")
dofile("script/shifts/shift4_4_animations.lua")

levelDesc.name = "Shift 4.4"
levelDesc.levelId = 44
levelDesc.musicMood = "3"
levelDesc.trigger =
{
	class = "TriggerSystem",
	triggers =
	{
		{ trigger = "spawn", delay=1000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "WAX", "LASER"} } },
		{ trigger = "spawn", delay=1000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "VITAMIN", "NITROGEN"} } },
		{ trigger = "spawn", delay=20000, hearts=3, diseaseDesc = { class="Disease", steps={"MIRROR", "CREAM",} } },
		{ trigger = "spawn", delay=1000, hearts=3, diseaseDesc = { class="Disease", steps={"MIRROR","WAX"} } },
		{ trigger = "spawn", delay=25000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "VITAMIN", "LASER",} } },
		{ trigger = "spawn", delay=1000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "CREAM", "NITROGEN",} } },
		{ trigger = "spawn", delay=18000, hearts=2, diseaseDesc = { class="Disease", steps={"WAX", "NITROGEN"} } },
		{ trigger = "spawn", delay=1000, hearts=2, diseaseDesc = { class="Disease", steps={"VITAMIN", "LASER"} } },
		{ trigger = "spawn", delay=25000, hearts=2, diseaseDesc = { class="Disease", steps={"MIRROR", "CREAM"} } },
		{ trigger = "spawn", delay=1000, hearts=2, diseaseDesc = { class="Disease", steps={"MIRROR", "WAX"} } },
		{ trigger = "spawn", delay=1000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "VITAMIN", "NITROGEN",} } },
		{ trigger = "spawn", delay=12000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "CREAM", "LASER",} } },
		{ trigger = "spawn", delay=25000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "WAX", "NITROGEN",} } },
		{ trigger = "spawn", delay=1000, hearts=1, diseaseDesc = { class="Disease", steps={"MIRROR", "WAX", "NITROGEN",} } },
		{ trigger = "spawn", delay=20000, hearts=2, diseaseDesc = { class="Disease", steps={"CREAM", "NITROGEN"} } },
		{ trigger = "spawn", delay=1000, hearts=2, diseaseDesc = { class="Disease", steps={"CREAM", "LASER"} } },
		{ trigger = "spawn", delay=23000, hearts=3, diseaseDesc = { class="Disease", steps={"VITAMIN",} } },
		{ trigger = "spawn", delay=1000, hearts=3, diseaseDesc = { class="Disease", steps={"WAX",} } },
		{ trigger = "spawn", delay=18000, hearts=2, diseaseDesc = { class="Disease", steps={"MIRROR", "CREAM"} } },
		{ trigger = "spawn", delay=1000, hearts=2, diseaseDesc = { class="Disease", steps={"MIRROR", "VITAMIN"} } },
		{ trigger = "spawn", delay=13000, hearts=3, diseaseDesc = { class="Disease", steps={"LASER",} } },
		{ trigger = "spawn", delay=1000, hearts=3, diseaseDesc = { class="Disease", steps={"NITROGEN",} } },
	}
}

levelDesc.patientList =
{
	p0 = { weight = 500,
		base = "axel",
	},
	p1 = { weight = 500,
		base = "lady",
	},
	p2 = { weight = 500,
		base = "teen",
	},
	p3 = { weight = 500,
		base = "local_male",
	},
	p4 = { weight = 500,
		base = "mother",
	},
}

function onObjectFound(event, obj)
	-- Move petals to table
	local pos_x = math.Random(180, 200)
	local pos_y = math.Random(218, 231)
	obj.floor = 100
	obj:animate({x=pos_x, y=pos_y, style="easeInOut", duration = 500})
end

levelDesc.eventDesc =
{
	class="HiddenObjectEvent",
	eventBarImage = "EVENTBAR_ICON_R4_S4:icons",
	funcFound = onObjectFound,
	hideAllObjects = true,
	scoreOneDone = 1,
	scoreAllDone = 1,
	eventBarText = "TEXT_EVENT_PETALS",
	showHintArrow = false,
	hintArrowObjectId = "EVENT_HIDDEN_ROSEPETAL_3",
}

function levelDesc:handleTrigger(trigger, meta)
	CareLevel.handleTrigger(self, trigger, meta)
	if (trigger == "pickup petal") then
		level:getObject("EVENT_HIDDEN_ROSEPETAL_9").visible = false
		eventBar:incValue(1)
		self.event.nrOfItems = self.event.nrOfItems - 1
		
	elseif (trigger == "pickup forgotten petals") then
		for i=1,10 do
			local obj = level:getObject("EVENT_HIDDEN_ROSEPETAL_"..i)
			if (obj.x > 200 or obj.y > 145) then
				local pos_x = math.Random(180, 200)
				local pos_y = math.Random(132, 145)
				obj:animate({delay=40*i}, {x=pos_x, y=pos_y, style="easeInOut", duration=300})
			end
		end
	end
end

function levelDesc:onShiftStartBegin()
	CareLevel.onShiftStartBegin(self)
	self.event:placeHintArrow()
end

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