dofile("script/layouts/room5_defaults.lua")
dofile("script/shifts/shift5_1_animations.lua")

levelDesc.name = "Shift 5.1"
levelDesc.levelId = 51
levelDesc.musicMood = "1"
levelDesc.trigger =
{
	class = "TriggerSystem",
	triggers =
	{
		{ trigger = "spawn", delay=2000, hearts=3, diseaseDesc = { class="Disease", steps={"WEIGHING", "YOGA"} } },
		{ trigger = "spawn", delay=8000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "STETHOSCOPE", "YOGA"} } },
		{ trigger = "spawn", delay=18000, hearts=3, diseaseDesc = { class="Disease", steps={"DIAPER_PRACTICE"} } },
		{ trigger = "spawn", delay=8000, hearts=3, diseaseDesc = { class="Disease", steps={"STETHOSCOPE"} } },
		{ trigger = "spawn", delay=17000, hearts=3, diseaseDesc = { class="Disease", steps={"WEIGHING", "YOGA"} } },
		{ trigger = "spawn", delay=10000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "DIAPER_PRACTICE",} } },
		{ trigger = "spawn", delay=5000, hearts=3, diseaseDesc = { class="Disease", steps={"STETHOSCOPE"} } },
		{ trigger = "spawn", delay=15000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "STETHOSCOPE"} } },
		{ trigger = "spawn", delay=8000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "YOGA"} } },
		{ trigger = "spawn", delay=10000, hearts=2, diseaseDesc = { class="Disease", steps={"STETHOSCOPE", "DIAPER_PRACTICE"} } },
		{ trigger = "spawn", delay=25000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "STETHOSCOPE", "YOGA"} } },
		{ trigger = "spawn", delay=7000, hearts=3, diseaseDesc = { class="Disease", steps={"DIAPER_PRACTICE"} } },
		{ trigger = "spawn", delay=8000, hearts=2, diseaseDesc = { class="Disease", steps={"STETHOSCOPE", "YOGA"} } },
		{ trigger = "spawn", delay=20000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "STETHOSCOPE"} } },
		{ trigger = "spawn", delay=8000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "YOGA"} } },
		{ trigger = "spawn", delay=8000, hearts=3, diseaseDesc = { class="Disease", steps={"YOGA", } } },
		{ trigger = "spawn", delay=8000, hearts=2, diseaseDesc = { class="Disease", steps={"WEIGHING", "STETHOSCOPE", "YOGA"} } },
		{ trigger = "spawn", delay=7000, hearts=2, diseaseDesc = { class="Disease", steps={"STETHOSCOPE", "DIAPER_PRACTICE"} } },
	}
}
levelDesc.patientList =
{
	p0 = { weight = 500,
		base = "preg",
	},
	p1 = { weight = 500,
		base = "preg2",
	},
	p2 = { weight = 500,
		base = "preg3",
	},
}

function onObjectFound(event, obj)
	-- Light candle
	obj:setFrame(1)

	local desc = {
		class = "SpriteExt",
		x = obj.width/2,
		y = -5,
		floor = 0,
		baseAnimation = "EVENT_HIDDENOBJECT_CANDLE_FLAME",
		anchor = "center",
		blendMode = "additive",
		alpha = 0,
	}
	local flame = obj:newChild(desc)
	flame:animate({startFrame=0, frameTime=100, loop="infinite"})
	flame:animate({blink={startAlpha=0.18, endAlpha=0.25, fadeIn=math.Random(100, 300), fadeOut=math.Random(100, 300)}})
end

levelDesc.eventDesc =
{
	class="HiddenObjectEvent",
	eventBarImage = "EVENTBAR_ICON_R5_S1:icons",
	funcFound = onObjectFound,
	scoreOneDone = 1,
	scoreAllDone = 10,
	eventBarText = "TEXT_EVENT_CANDLES",
	hintArrowObjectId = "EVENT_HIDDEN_CANDLE_10",
}

function levelDesc:onShiftStartEnd()
	self:fireTrigger("startEvent")
end

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

function levelDesc:onTick(time)
    self:tick(time)
	self:randomSneeze(time)
end
