class 'l_04_Gazebo_Z_Railing' (ZoomZone)

---------------------------------------------------------------------------------
local DTIME = 0.5
---------------------------------------------------------------------------------

function l_04_Gazebo_Z_Railing:__init(name, mode, PlayField)
	ZoomZone.__init(self, name, mode, PlayField)
	
	self:entityHide('area_apply_zr_coal_1', 'area_apply_zr_coal_2','area_bbt_zr_tablet')
	
	self:entityHide('zr_code_label_1', 'zr_code_label_2','zr_number_1','zr_number_2')
	
	---------------------------------------------------------------------------------
	do
		local function on_find_zr_number_key_03(e)
		    self:entityHide(e.target)
		    
		    self:entityHide('zr_number_key_03')
		end
		self:registerToolFindInfo('04_number_key_3', 'area_find_zr_number_key_03', on_find_zr_number_key_03)
	end
	---------------------------------------------------------------------------------
	
	---------------------------------------------------------------------------------
	do
		local function on_click_zr_tablet(event)
		    self:entityHide(event.target)
		    self:entityShow('area_apply_zr_coal_1','area_apply_zr_coal_2')
		    
		    if not event.save then
		    	self:playSound('04_click_zr_tablet')
		    	self:getEntityNamed('zr_tablet'):ChangeScaleX(-1, 1, DTIME)
		    	
		    	self.timer:add( function()
		    						self:entityShow('area_apply_zr_coal_1','area_apply_zr_coal_2')
		    						self:entityShow('zr_code_label_1')
		    					end, DTIME/2)
		    else
		    	self:getEntityNamed('zr_tablet'):setScaleX(1)
		    	self:entityShow('area_apply_zr_coal_1','area_apply_zr_coal_2')
	        	self:entityShow('zr_code_label_1')
		    end
		end
		self:registerActiveObject('area_click_zr_tablet', on_click_zr_tablet)
	end
	---------------------------------------------------------------------------------

	---------------------------------------------------------------------------------
	do
		local apply_coal_counter = 2	
		local function on_apply_zr_coal(event)		
		    self:entityHide(event.target)
			local i = string.sub(event.target, -1)    
		    self:entityHide('zr_code_label_1')
		    self:entityShow('zr_code_label_2')
		    
		    if not event.save then
		    	self:playSound('04_apply_coal')
		        self:entityFadeShow('zr_number_'..i)
		    else
		   		self:entityShow('zr_number_'..i)
		    end
		    apply_coal_counter = apply_coal_counter - 1

		    if apply_coal_counter<=0 then
			    self:entityShow('area_bbt_zr_tablet')
			    self.playfield:addNote('Note_04_Code')
			    self.playfield.zoom_tool_box:setCodeIsKnown()
		    end
		end
		self:registerToolApplyInfo('05_coal', {'area_apply_zr_coal_1', 'area_apply_zr_coal_2'}, on_apply_zr_coal, 'BBT_04_NEED_COAL')
		
		self:registerBBT('area_bbt_zr_tablet', 'BBT_04_TABLET')
	end	
	---------------------------------------------------------------------------------
end

--------------------------------------------------------------------------------
--                      GENERATED CONTENT. DO NOT EDIT.                       --
--------------------------------------------------------------------------------

function l_04_Gazebo_Z_Railing:CreateLoaderTable()
	local objects =
	{
		{ name = 'zr_bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_bg.jpg',  width = 640,  height = 480,  },
		{ name = 'zr_table_hook',  entityType = 'SpriteEntity',  x = 492,  y = 282,  order = 12,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_table_hook.png',  width = 31,  height = 36,  },
		{ name = 'zr_tablet',  entityType = 'SpriteEntity',  x = 493,  y = 307,  order = 10,  isRespondable = true,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_tablet.png',  width = 131,  height = 84,  },
		{ name = 'zr_code_label_1',  entityType = 'SpriteEntity',  parentName = 'zr_tablet',  x = 0,  y = 0,  order = 15,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_tablet_1.png',  width = 131,  height = 84,  },
		{ name = 'zr_label_1',  entityType = 'TextEntity',  parentName = 'zr_code_label_1',  x = 0,  y = -4,  order = 0,  isRespondable = true,  color = {r = 0, g = 0, b = 0, a = 1},  editingLocked = false,  treeItemIsExpanded = false,  text = 'Height',  height = 21,  },
		{ name = 'zr_label_m_1',  entityType = 'TextEntity',  parentName = 'zr_code_label_1',  x = 38,  y = 25,  order = 0,  isRespondable = true,  color = {r = 0, g = 0, b = 0, a = 1},  editingLocked = false,  treeItemIsExpanded = false,  text = 'm',  height = 21,  },
		{ name = 'zr_code_label_2',  entityType = 'SpriteEntity',  parentName = 'zr_tablet',  x = 0,  y = 0,  order = 20,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_tablet_1.png',  width = 131,  height = 84,  },
		{ name = 'zr_number_1',  entityType = 'SpriteEntity',  parentName = 'zr_code_label_2',  x = -39,  y = 21,  order = 16,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_number_3.png',  width = 35,  height = 37,  },
		{ name = 'zr_label_m_2',  entityType = 'TextEntity',  parentName = 'zr_code_label_2',  x = 38,  y = 25,  order = 22,  isRespondable = true,  color = {r = 0, g = 0, b = 0, a = 1},  editingLocked = false,  treeItemIsExpanded = false,  text = 'm',  height = 21,  },
		{ name = 'zr_label_2',  entityType = 'TextEntity',  parentName = 'zr_code_label_2',  x = 0,  y = -4,  order = 20,  isRespondable = true,  color = {r = 0, g = 0, b = 0, a = 1},  editingLocked = false,  treeItemIsExpanded = false,  text = 'Height',  height = 21,  },
		{ name = 'zr_number_2',  entityType = 'SpriteEntity',  parentName = 'zr_code_label_2',  x = 5,  y = 20,  order = 16,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_number_6.png',  width = 41,  height = 40,  },
		{ name = 'zr_number_key_03',  entityType = 'SpriteEntity',  x = 362,  y = 571,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_number_key_03.png',  width = 60,  height = 58,  },
		{ name = 'zr_cover',  entityType = 'SpriteEntity',  x = 356,  y = 566.5,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/04_Gazebo/Z_Railing/zr_cover.png',  width = 140,  height = 116,  },
		{ name = 'area_find_zr_number_key_03',  entityType = 'SpriteEntity',  x = 362,  y = 564,  order = 0,  isRespondable = true,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_click_zr_tablet',  entityType = 'SpriteEntity',  x = 483,  y = 319,  order = 100,  isRespondable = true,  scaleX = 1.7,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_bbt_zr_tablet',  entityType = 'SpriteEntity',  x = 483,  y = 319,  order = 100,  isRespondable = true,  scaleX = 1.7,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_apply_zr_coal_1',  entityType = 'SpriteEntity',  x = 431,  y = 317,  order = 100,  isRespondable = true,  scaleX = 1.2,  scaleY = 1.7,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_apply_zr_coal_2',  entityType = 'SpriteEntity',  x = 552,  y = 319,  order = 100,  isRespondable = true,  scaleX = 1.2,  scaleY = 1.7,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
	}
	return objects
end
