
--script de la classe des boject de closeup à chercher

.namespace CloseupObject

DataSound = 
{
	s01_cup01_Closeup = "gp_c01_s01_cup01_papier",
	s02_cup01_Closeup = "gp_c01_s02_cup01_objet",
	s05_cup01_Closeup ="gp_c01_s05_cup01_clef",
	s06_cup01_Closeup ="gp_c01_s06_cup01_ecrou",
	s07_cup01_Closeup ="gp_c01_s07_cup01_cle",
	s10_cup01_Closeup ="gp_c01_s10_cup01_papier",
	s12_cup01_Closeup ="gp_c01_s12_cup01_objet",
	s14_cup01_Closeup ="gp_c01_s14_cup01_bille",
	s16_cup01_Closeup ="gp_c01_s16_cup01_os",
	s19_cup01_Closeup ="gp_c01_s19_cup01_buchette",
	s21_cup01_Closeup ="gp_c01_s21_cup01_verre",
	s24_cup01_Closeup ="gp_c01_s24_cup01_engrenage"
	
}

function OnEnable()
	self.picked = false
end

function GetRefPositionWithoutParent()
	if self.refpointx ~= nil then
		return (self.Position_X + self.refpointx),(self.Position_Y + self.refpointy)
	else
		return (self.Position_X + self.Dimension_Width/2),(self.Position_Y + self.Dimension_Height/2)
	end
end

function OnWbpMouseLUp(x,y,buttonPressed)

	if not self.picked then
		OPLog.Log("click sur "..self.Name)
		self.picked = true
		ObjectManager.OnMoveEndParticules(self.Name)
		SpriteFader.Fade(self,false,0.4)
		
		-- Vérifie s'il y a un son, spécifique, sinon joue un son de prise d'objet générique
		-- TODO : est-ce qu'on garde ça ?
		if DataSound[self.Parent.Parent.Name] ~= nil then
			PlaySoundEffect(DataSound[self.Parent.Parent.Name])
		else
			PlayRandomSound({"int_priseobjet01","int_priseobjet02","int_priseobjet03"})
		end
		
		return true
	end
end

function CanClickOn()
	local res = self.Flags_Visible and IsEqualVariables("CurrentGamePhase","Closeup")

	return res
end


function OnDisable()
	
end


function SetCursor()
	return false
end


function SetUnitToNotify( ut )
	self.UnitToNotify = ut
end


function GetUnitToNotify()
	if self.UnitToNotify ~= nil then
		return self.UnitToNotify
	end
	
	return nil
end


