class 'l_01_Boat_crash_site_Z_Box' (ZoomZone)

function l_01_Boat_crash_site_Z_Box:__init(name, mode, PlayField)
	ZoomZone.__init(self, name, mode, PlayField)
	
	----------------------------------------------------------------------------
	self:entityHide('area_find_zb_fish', 'area_find_zb_box')	
	self:entityHide('zb_net', 'zb_box_2', 'zb_net_after', 'zb_fish_anim')
	----------------------------------------------------------------------------	

	----------------------------------------------------------------------------
    if (not IsToolApplied('01_fishing_net')) then
        self.dog_idle 		= createVideo({video = 'dog_idle_01', order = 60, x = 436, y = 402, isLooped = true, isAlpha = true})
        self.dog_z_idle 	= createVideo({video = 'dog_idle_z_01', order = 60, x = -100, y = -171, isLooped = true, isAlpha = true, parent = self.main_entity})

        self.dog_idle:play()
        self.dog_z_idle:play()
    end   
    ----------------------------------------------------------------------------

    -- apply fishing net -------------------------------------------------------
    do	
		local function on_apply_zb_fishing_net(e)
		    self:entityHide(e.target)		      
		    self:stopSound('dog_idle_z_01')
		    self:entityShow('area_find_zb_fish', 'area_find_zb_box')	    
		    
		    self.playfield:entityHide('box_1')
		   
	        self.playfield:entityShow('box_2')  

			self.playfield.l_box_moln_1:setOpacity(1)	
			self.playfield.l_box_1:setOpacity(1)
			self.playfield.l_box_moln_2:setOpacity(1)
			self.playfield.l_box_2:setOpacity(1)

			self.playfield.w_box_moln_1:setOpacity(0)	
			self.playfield.w_box_1:setOpacity(0)
			self.playfield.w_box_moln_2:setOpacity(0)
			self.playfield.w_box_2:setOpacity(0)
	            
		    function cut_scene_dog()
	        	self.dog_find 		= createVideo({video = 'dog_loc1_nose_running', order = 60, x = 798, y = 615, isLooped = false, isAlpha = true})
		  		self.playfield:startCutScene(self.dog_find , nil, 5)
		  		self:playSound('dog_loc1_nose_running')
		  		self.timer:add( function()
						  			 self.dog_find:hide()
						  		end, 5)
	        end

		    if not e.save then
		    	self.dog_idle:hide() 
		    	self.dog_z_idle:hide() 
		    	
		        self:entityShow('zb_net')
		        self:playSound('01_apply_zb_fishing_net')
		        self.mouseBlocker:push()

				self:getEntityNamed('compositionfon'):getElementByName('box_water'):ChangeOpacity(1, 0, 0.5)
				self:getEntityNamed('compositionfon'):getElementByName('wave_4'):ChangeOpacity(1, 0, 0.5)
				self:getEntityNamed('compositionfon'):getElementByName('wave_3'):ChangeOpacity(1, 0, 0.5)

		        self:entityFadeHide('zb_net', 'zb_box_1')
		        self:entityFadeShow('zb_box_2', 'zb_fish_anim')
		        self:getEntityNamed('zb_fish_anim'):play()
		        
		        self:close()		  		
		        self.timer:add( function()
					                self.mouseBlocker:pop()
					               
					                self:findTool('dog', nil, nil)
					                completeGameTask('02')
					            end, ZOOM_ZONE_APPEARING_TIME )
		    else	        
		    	self:getEntityNamed('compositionfon'):getElementByName('box_water'):setOpacity(0)
		    	self:getEntityNamed('compositionfon'):getElementByName('wave_4'):setOpacity(0)
		    	self:getEntityNamed('compositionfon'):getElementByName('wave_3'):setOpacity(0)
		        self:entityHide('zb_box_1')
		        self:entityShow('zb_box_2')
		        self:entityShow('zb_fish_anim')
		        self:getEntityNamed('zb_fish_anim'):play()
		        self:findTool('dog', nil, nil)

		        self.timer:add( function()
					    	   		completeGameTask('02')
						    	end, 0)
		    end
		end
		self:registerToolApplyInfo('01_fishing_net', 'area_apply_zb_fishing_net', on_apply_zb_fishing_net, 'BBT_01_NEED_FISHING_NET')	
	end
	----------------------------------------------------------------------------

	----------------------------------------------------------------------------
	local close_counter = 3
	local function decrement_close_counter()
	    close_counter = close_counter - 1
	    if close_counter <= 0 then
	        self:closeAndDisable()
	    end
	end	
	----------------------------------------------------------------------------
	
	-- find fish ---------------------------------------------------------------
	do
		local function on_find_zb_fish(e)
	        self:entityHide(e.target)
	        
	        self:entityHide('zb_fish_anim')
	        
	        decrement_close_counter()
		end
		self:registerToolFindInfo('01_fish', 'area_find_zb_fish', on_find_zb_fish)
	end
	----------------------------------------------------------------------------

	-- find fish ---------------------------------------------------------------
	do
		local function on_find_zb_box(e)
	        self:entityHide(e.target)
	        
	        self:entityHide('zb_box_2')
	        self:entityShow('zb_net_after')
	        
	        self.playfield:entityHide('box_2')
	        
	        self.playfield.l_net_moln_1:setOpacity(1)
	  		self.playfield.l_net_1:setOpacity(1)
	   		self.playfield.l_net_moln_2:setOpacity(1)
	    	self.playfield.l_net_2:setOpacity(1)
	    	self.playfield.l_box_moln_1:setOpacity(0)	
	    	self.playfield.l_box_1:setOpacity(0)
	    	self.playfield.l_box_moln_2:setOpacity(0)
	    	self.playfield.l_box_2:setOpacity(0)
	       
	        self.playfield:entityShow('net_after')
	       
	        decrement_close_counter()
		end
		self:registerToolFindInfo('01_box', 'area_find_zb_box', on_find_zb_box)
	end
	----------------------------------------------------------------------------

	-- find fish ---------------------------------------------------------------
	do
		local function on_apply_zb_empty_bottle_bag(e)
		    self:entityHide(e.target)
		    
		    decrement_close_counter()
		    
		    self:findTool('01_bottle_with_water')	    	    
		end
		self:registerToolApplyInfo('05_empty_bottle_bag', 'area_apply_zb_empty_bottle_bag', on_apply_zb_empty_bottle_bag, 'BBT_01_NEED_EMPTY_BOTTLE_BAG')
	end
	----------------------------------------------------------------------------
end
----------------------------------------------------------------------------

----------------------------------------------------------------------------
function l_01_Boat_crash_site_Z_Box:onOpen()
	if (not IsToolApplied('01_fishing_net')) then   
		self:stopSound('dog_idle_z_01')
	    self:playSound('dog_idle_z_01', true)
	end
end	
----------------------------------------------------------------------------

----------------------------------------------------------------------------
function l_01_Boat_crash_site_Z_Box:onClose()
	self:stopSound('dog_idle_z_01')
end	
----------------------------------------------------------------------------

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

function l_01_Boat_crash_site_Z_Box:CreateLoaderTable()
	local objects =
	{
		{ name = 'zb_bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_bg.jpg',  width = 640,  height = 480,  },
		{ name = 'zb_fish_anim',  entityType = 'SpriteEntity',  x = 621,  y = 539,  order = 15,  isVisible = false,  isRespondable = true,  scale = 1.2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_fish_anim.png',  width = 65,  height = 65,  mode = 4,  fps = 12,  framesCount = 4,  },
		{ name = 'zb_box_2',  entityType = 'SpriteEntity',  x = 619,  y = 464,  order = 10,  isVisible = false,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_box_2.png',  width = 426,  height = 320,  },
		{ name = 'zb_net_after',  entityType = 'SpriteEntity',  x = 472,  y = 545,  order = 14,  isVisible = false,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_net_after.png',  width = 358,  height = 152,  },
		{ name = 'zb_box_1',  entityType = 'SpriteEntity',  x = 447.5,  y = 304.5,  order = 30,  isVisible = false,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_box_1.png',  width = 237,  height = 191,  },
		{ name = 'zb_net',  entityType = 'SpriteEntity',  x = 579.5,  y = 366,  order = 40,  isVisible = false,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 252.5, y = 148},  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Z_Box/zb_net.png',  width = 505,  height = 296,  },
		{ name = 'area_find_zb_box',  entityType = 'SpriteEntity',  x = 615,  y = 464,  order = 100,  isRespondable = true,  angle = -7,  scaleX = 3.8,  scaleY = 1.8,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_apply_zb_fishing_net',  entityType = 'SpriteEntity',  x = 453,  y = 298,  order = 100,  isRespondable = true,  scaleX = 2.5,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 150,  },
		{ name = 'area_find_zb_fish',  entityType = 'SpriteEntity',  x = 618,  y = 541,  order = 110,  isRespondable = true,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Common/Area_Round.png',  width = 128,  height = 128,  },
		{ name = 'area_apply_zb_empty_bottle_bag',  entityType = 'SpriteEntity',  x = 489,  y = 246,  order = 99,  isRespondable = true,  angle = -15,  scaleX = 7.2,  scaleY = 3.5,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = '01_Boat_crash_site_Anim_Z_Box',  entityType = 'CompositionContainer',  x = 192,  y = 144,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/01_Boat_crash_site/Anim/01_Boat_crash_site_Anim_Z_Box.lua',  },
		{ name = 'compositionfon',  entityType = 'CompositionSequence',  parentName = '01_Boat_crash_site_Anim_Z_Box',  x = 0,  y = 0,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
	}
	return objects
end
