--[[ script de gestion de la classe SpriteDragged --]]

.namespace Spritedragged
--un sprite à dragger.


function OnEnable()
	
end




-- on intercepte le click pour les objets cachés
function OnWbpMouseLDown(x,y)
	if self.CanClickOn() then
		OPLog.Log("on a intercepté le click sur "..self.Name.." !")
		piecedragged = OPUnitFactory.GetUnit(tostring(self.Name))
		
		
		if dragged==false then
			dragged=true
			piecedragged.Layer=LayerForeground
		else 
			dragged=false
			piecedragged.Layer=LayerMiddleground
		end
		return true
	end
	return false
end



function SetCursor()
	if self.CanClickOn() then
		OPUnitFactory.GetUnit("Cursor","Cursor").ChangeCursorToGeneric()
		return true
	end
	return false
end


function CanClickOn()
	return self.Flags_Visible 
		and ( GameVariables.IsEqual("CurrentGamePhase", "SearchSite") or GameVariables.IsEqual('CurrentGamePhase','Closeup'))
end