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

	stars:Show("M_HAND", "4")
end
--------------------------------------------------------------------------------
function OnMouseClickOnBack()
	chapter:ExitCloseup()
	return true
end
--------------------------------------------------------------------------------
function OnMouseClickOnItem(item)
	local itemName = item:GetName()
	
	if itemName == "M_HAND" then				--рука
		comment:Add("CMT_Hand_Player")
		return true
	end
	
	if itemName == "M_BRACELET" then			--браслет
		item:Hide()
		room:GetItem("STATUE_HAND_BRACELET"):SetAnimPause(false)
		room:AddCtrlAnimation("STATUE_HAND_BRACELET", -1)
		room.sfx:Play("take_bracelet")
		return true
	end
end
--------------------------------------------------------------------------------
function OnClickItemOnItem(item)					
	local itemName = item:GetName()
	
	if itemName == "M_HAND" then				--медное кольцо на руку  
		if cursor:IsItemNameEqual("COPPER_RING") then			
			cursor:RemoveItem()
			item:Hide()
			room:GetItem("HAND"):Hide()
			
			--запустить видео одевания кольца
			local videoRing = room:GetItem("STATUE_HAND_RING")
			videoRing:Show()
			videoRing:PlayAnimation()
			room:AddCtrlAnimation("STATUE_HAND_RING", -1)
			
			room.sfx:Play("get_bracelet")
			return true
		end
	end
end
--------------------------------------------------------------------------------
-- Окончание анимации одевания кольца
function OnAnimationComplete_STATUE_HAND_RING(forced)
	room:GetItem("STATUE_HAND_RING"):Hide()
	room:GetItem("M_BRACELET"):Show()
	local videoBracelet = room:GetItem("STATUE_HAND_BRACELET")
	videoBracelet:Show()
	videoBracelet:PlayAnimation()
	videoBracelet:SetAnimPause(true)
end
--------------------------------------------------------------------------------
-- Окончание анимации поворачивания руки
function OnAnimationComplete_STATUE_HAND_BRACELET(forced)
	cstore:SetKey("Close_up_Statue", true)
	room:MarkCompleted()
	
	if forced == true then
		inventory:CreateAndAddItem(room:GetItem("CASKET_KEY"))
	else
		pick_panel:AddItems("CASKET_KEY", true)
	end
end