-- ************************************ GameHouseObject ************************************ --
GameHouseObject = deriveLuaClass("GameHouseObject", "Object")

function GameHouseObject:init(desc)
	GameHouseObject.superInit(desc)

	self.drawOutline = false
	self.clickable = true

	if (player:hasFoundGameHouseObject(self.gameHouseId)) then
		self.visible = false
	end
end

function GameHouseObject:onClick()
	if (self.visible) then
		self.clickable = false
		player:foundGameHouseObject(self.gameHouseId)

		level:doFloater(ghf.getString("GH_FOUND"), self.x, self.y-30)
		level:incPaused()

		local x = self.left + self.width/2
		local y = self.top + self.height/2
		scene:newChild({class="ParticleEffect", library="MINIGAME_GOOD", section="objects", x=x, y=y, start=true})
		scene:newChild({class="ParticleEffect", library="FOUND_GUINEAPIG", section="objects", x=x, y=y, start=true})
		scene:newChild({class="ParticleEffect", library="FOUND_GUINEAPIG", section="objects", x=x, y=y, start=true, rotation=180})

		self:animate({
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{alpha=0, duration=1}, {delay=60},
			{alpha=1, duration=1}, {delay=60},
			{call=function()
				local dlg = scene:createDialog("gamehouse_object")
				scene:openDialog(dlg)
				dlg:getChild("STAR"):animate({ {scale=1, duration=50}, {rotation="clockwise", duration=9000}, })
				dlg:getChild("PIC").image = "GH_"..self.gameHouseId.."_BIG:objects"
				dlg:getChild("HEAD").textId = "GH_OBJ_HEAD"..self.gameHouseId
				dlg:getChild("TEXT").textId = "GH_OBJ_TEXT"..self.gameHouseId
				dlg:getChild("OK").onClick = function() dlg:close() end
				dlg.onHide = function() level:decPaused() end
			end},
			{remove=true},
		})
	end
end
