--------------------------------------------------------------------------------
--  File     : Chapel_ext
--  Author(s): Prokopovich Larisa
--
--  Summary  : Скрипт управления локацией.
--
--  Copyright © 2012 Floodlight Games.  All rights reserved.
--------------------------------------------------------------------------------
function OnFirstEntry()
	room:GetItem("M_TO_CHAPEL_INT"):Disable ()

	stars:Show("M_TO_CEMETERY", "3")
	stars:Show("M_TO_CHAPEL_INT", "2")
	stars:Show("M_CEMETERY_GATE", "4")
	stars:Show("M_CEMETERY", "4")
end
--------------------------------------------------------------------------------
function OnEntry()
	music:PlayLoopWithDelay(10, "The_Mist")
	ambient:Play("Chapel_ext")
end
--------------------------------------------------------------------------------
function OnMouseClickOnItem(item)
	local itemName = item:GetName()
	
	if itemName == "M_TO_STREET" then										--переход в деревню
		chapter:JumpRoom("Village_street")
		return true
	elseif itemName == "M_TO_CHAPEL_INT" then								--переход в часовню
		if item:IsEnabled() then
			chapter:JumpRoom("Chapel_int")		
		else
			chapter:JumpRoom("Chapel_ext_Door_MG")
		end
		return true
	elseif itemName == "M_TO_CEMETERY" then									--переход на кладбище
		chapter:JumpRoom("Cemetery")
		return true
	end
	
	if itemName == "M_CEMETERY_GATE" then				--ворота кладбища
		comment:Add("CMT_Gate_Player")
		return true
		
	elseif itemName == "M_CEMETERY" then				--кладбище
		comment:Add("CMT_Cemetery_Player")
		return true
	end
	
end
--------------------------------------------------------------------------------
function OnClickItemOnItem(item)					
	local itemName = item:GetName()

	if itemName == "M_CEMETERY_GATE" then				--ключ на ворота
		if cursor:IsItemNameEqual("CEMETERY_KEY") then			
			cursor:RemoveItem()
			item:Hide()
			room:GetItem("M_CEMETERY"):Hide()
			room:GetItem("M_TO_CEMETERY"):Show()
			room:GetItem("LOCKED_GATE"):Hide()
			room:GetItem("OPENED_GATE"):Show()
			room.sfx:Play ("gate_open")		--звук "калитка на кладбище открывается"
			return true
		end
	end
end
--------------------------------------------------------------------------------
function OnChapterStoreEvent_Chapel_door(value)							--выход из миниигры с дверью
	room:GetItem("M_TO_CHAPEL_INT"):Enable ()
	stars:Hide("M_TO_CHAPEL_INT")
	stars:Show("M_TO_CHAPEL_INT", "3")
end
--------------------------------------------------------------------------------
function OnChapterStoreEvent_Cheat_ChapelExt(value)						--выполнить все в локации  !!!
	room:GetItem("M_TO_CHAPEL_INT"):Enable ()
	stars:Hide("M_TO_CHAPEL_INT")
	stars:Show("M_TO_CHAPEL_INT", "3")
	
	room:GetItem("M_TO_CEMETERY"):Enable ()
	room:GetItem("LOCKED_GATE"):Hide()
	room:GetItem("OPENED_GATE"):Show()
	stars:Hide("M_TO_CEMETERY")
	stars:Show("M_TO_CEMETERY", "3")
end
