class 'l_02_Mountain_path_Z_Eagle' (ZoomZone)

function l_02_Mountain_path_Z_Eagle:__init(name, mode, PlayField)
	ZoomZone.__init(self, name, mode, PlayField)
	
	self:entityHide('area_apply_ze_strong_rope_net', 'ze_rope', 'ze_eagle_action', 'ze_eagle_fly')
	
	self:getEntityNamed('ze_eagle_idle'):play()
	
	

	local function on_click_fish_apply()
		self:entityShow('ze_eagle_action')
		self:entityHide('area_apply_ze_fish')

		self:getEntityNamed('ze_eagle_action'):stop()
		self:getEntityNamed('ze_eagle_action'):play()
		
		self:stopSound('02_ze_eagle_action_2')
		self:playSound('02_ze_eagle_action_2')

		self:entityFadeHide('ze_eagle_idle')
		
		local function on_end()
			self:entityHide('ze_eagle_action')
			self:entityShow('ze_eagle_idle', 'area_apply_ze_fish')
			
		end

		self:getEntityNamed('ze_eagle_action').onFinish:add( on_end )
		
		return 'BBT_02_NEED_FISH'
	end
	
	local function on_apply_ze_fish(e)
	    self:entityHide(e.target)	    
	    
	    if not e.save then	    
	    	self:entityShow('ze_eagle_fly')	
	    	self:entityFadeHide('ze_eagle_idle')
	    	self.playfield:entityFadeShow('bg_eagle_fly')
	    	self.playfield:getEntityNamed('bg_eagle_fly'):stop()
	    	self.playfield:getEntityNamed('bg_eagle_fly'):play()
	    	self.timer:add(function()
	               self.playfield:getEntityNamed('bg_eagle_fly'):ChangeOpacity(1, 0, 2)
	        end, 8)

	    	self:getEntityNamed('ze_eagle_fly'):play()
	    	self:playSound('02_ze_apply_fish_eagle_fly')

	    	local function on_end()
	    		self:getEntityNamed('ze_eagle_fly'):hide()
	    		self:getEntityNamed('ze_eagle_idle'):stop()
	    		
				self:entityShow('area_apply_ze_strong_rope_net')
			end

			self:getEntityNamed('ze_eagle_fly').onFinish:add( on_end )
	        self.playfield:getEntityNamed('composition_layer_3'):getElementByName('eagle'):ChangeOpacity(1, 0, 0.5)
	    else
	    	self:entityHide('ze_eagle_idle')
	    	self.playfield:getEntityNamed('bg_eagle_fly'):hide()
	    	self:entityShow('area_apply_ze_strong_rope_net')
	     	self.playfield:getEntityNamed('composition_layer_3'):getElementByName('eagle'):setOpacity(0)
	    end   
	end
	self:registerToolApplyInfo('01_fish', 'area_apply_ze_fish', on_apply_ze_fish, on_click_fish_apply)
	
	local function on_apply_ze_strong_rope_net(e)
	    self:entityHide(e.target)
	    self.playfield:entityShow('area_apply_loaded_harpoon')
	    
	    self:entityShow('ze_rope')
	    
	    self.playfield:entityShow('rope_clew') 
	    
	    self:closeAndDisable()

	    if not e.save then 
	    	self:playSound('02_apply_ze_strong_rope_net')
		end
	end
	self:registerToolApplyInfo('01_strong_rope_net', 'area_apply_ze_strong_rope_net', on_apply_ze_strong_rope_net, 'BBT_02_NEED_STRONG_ROPE_NET')
end

--------------------------------------------------------------------------------
function l_02_Mountain_path_Z_Eagle:onCloseFinished()
	self:stopSound('02_ze_eagle_action_2')
	self:getEntityNamed('ze_eagle_action'):stop()
	self:getEntityNamed('ze_eagle_action'):hide()

	if not IsToolApplied('01_fish') then
		self:entityShow('ze_eagle_idle', 'area_apply_ze_fish')
	end
end
--------------------------------------------------------------------------------

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

function l_02_Mountain_path_Z_Eagle:CreateLoaderTable()
	local objects =
	{
		{ name = 'ze_bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/02_Mountain_path/Z_Eagle/ze_bg.jpg',  width = 384,  height = 512,  },
		{ name = 'area_apply_ze_fish',  entityType = 'SpriteEntity',  x = 511,  y = 384,  order = 100,  scaleX = 3.84,  scaleY = 5.12,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 50, y = 50},  width = 100,  height = 100,  },
		{ name = 'area_apply_ze_strong_rope_net',  entityType = 'SpriteEntity',  x = 523,  y = 536,  order = 100,  scaleX = 1,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 198,  height = 177,  },
		{ name = 'ze_ring',  entityType = 'SpriteEntity',  x = 524,  y = 563,  order = 15,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/02_Mountain_path/Z_Eagle/ze_ring.png',  width = 76,  height = 82,  },
		{ name = 'ze_rope',  entityType = 'SpriteEntity',  x = 515,  y = 605,  order = 10,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/02_Mountain_path/Z_Eagle/ze_rope.png',  width = 48,  height = 68,  },
		{ name = 'ze_cover',  entityType = 'SpriteEntity',  x = 521,  y = 527,  order = 20,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/02_Mountain_path/Z_Eagle/ze_cover.png',  width = 26,  height = 38,  },
		{ name = 'ze_eagle_idle',  entityType = 'VideoEntity',  x = 674,  y = 298,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Video/Scenes/02_Mountain_path/eagle_idle.webm',  hotSpot = {x = 256, y = 128},  hasAlpha = true,  isLooped = true,  fps = 24,  },
		{ name = 'ze_eagle_fly',  entityType = 'VideoEntity',  x = 512,  y = 328,  order = 205,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/02_Mountain_path/eagle_fly.webm',  hasAlpha = true,  isLooped = false,  fps = 24,  },
		{ name = 'ze_eagle_action',  entityType = 'VideoEntity',  x = 704,  y = 294,  order = 200,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/02_Mountain_path/eagle_action.webm',  hotSpot = {x = 384, y = 200},  hasAlpha = true,  isLooped = false,  fps = 24,  },
	}
	return objects
end
