class 'l_06_Town' (PlayField)

function l_06_Town:__init(game_scene, name, path)
	PlayField.__init(self, game_scene, name, path)
	
	-- links ---------------------------------------------------------------
	self:linkScene('area_link_05',   'CursorDown',    		'05_Forest_path')	
	self:linkScene('area_link_07',   'CursorUp',      		'07_Cantellos_shop')	
	self:linkScene('area_link_08',   'CursorUp',      		'08_Lauras_room')	
	self:linkScene('area_link_09',   'CursorRightUp',      	'09_Andreas_house')	
	self:linkScene('area_link_10',   'CursorUp',      		'10_Dead_ship_shore')	
	------------------------------------------------------------------------
	-- 
	-- cutscene ------------------------------------------------------------
	self:FirstCutscene()

	self:addNote('Note_06_Molinari')
	
	self:entityHide('area_zoom_Paper_Plane', 'area_link_09', 'Layer_rope_trap', 'Layer_plane', 'Layer_cover_handle',
					'Layer_hole', 'compositionloc_06_bg', 'compositionloc_06_new_2', 'compositionloc_06_new', 'area_link_08')

	self:registerBBT('area_link_09BBT', 'BBT_06_LINK_ON_09')
	self:registerBBT('bbt_06_vortex', 'BBT_06_VORTEX')
    self:registerBBT('area_bbt_cantello_shop', 'BBT_06_CANTELLO_SHOP')

    do 
		if IsToolFound('06_skeleton_key') and not HasGameState('06_FINDED_SCELETON_KEY') then
			SetGameState('06_FINDED_SCELETON_KEY', 'true')

			local node = path_manager:findNode(NodeType.SCENE, '07_Cantellos_shop')
	        if node then
	            node:setState(NodeState.ENABLED)
	        end  
		end
	end
		   
	do  -- find clock -----------------------------------------------------   
	    if not self:isObjectClicked('area_click_clock_4') then
	    	self:getEntityNamed('area_click_clock_4'):hide()
	        self.timer:add( function() 
                            	self:fadeGhostClock('clock_4', 'cover_clock_4', 'area_click_clock_4')
                            end, 35)   
	    end
	
        function on_click(event)
           	self:entityHide('clock_4')
            self:entityHide('area_click_clock_4')
            if not event.save then  
                self:entityFadeHide('cover_clock_4') 
            else 
                self:entityHide('cover_clock_4') 
            end
	    end
	    self:registerFindClockObject('area_click_clock_4', 'fly_clock_4', 'clock_4', on_click)
	end

	-- find photo ---------------------------------------------------------------
    do
        local function on_take_photo(event)    
           -- self:entityShow('')     
        end
        self:registerFindFlyPhoto('area_find_photo', '06_Molinari' , on_take_photo)
    end
    -- find photo ---------------------------------------------------------------

	if IsToolApplied('04_letter_to_laura') and HasGameState('06_molinari_running_end') then
		self:entityShow('area_zoom_Paper_Plane','Layer_plane')
		if not HasGameState('06_plane_cutscene_end') then
			SetGameState('06_plane_cutscene_end', 'true')
			self.layer_papper_cutscene 		= createVideo({video = 'papper_plane', sound = 'papper_plane', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false})
	  		self:startCutScene(self.layer_papper_cutscene , nil, nil, '06_Laura_CutScene')
		end
	end

	if isSceneVisited('08_Lauras_room') then
		if not HasGameState('06_laura_cutscene_end') then
			SetGameState('06_laura_cutscene_end', 'true')
			self:entityShow('compositionloc_06_new_2')
			self:getEntityNamed('compositionloc_06_new_2'):play()

			self:focusOnLocationAndrea()
		else
			self:entityShow('compositionloc_06_new_2')
		 	self:getEntityNamed('compositionloc_06_new_2'):rewind(true)	
		end

		-- if not HasGameState('06_laura_cutscene_end') then	
		-- 	addGameTask('15')
		-- 	local function on_end_cutscene()
		-- 		self:entityShow('compositionloc_06_new_2')
		-- 		self:getEntityNamed('compositionloc_06_new_2'):play()

		-- 		self:focusOnLocationAndrea()
		-- 		self:showBlackBar('BBT_06_CANTELLLO_SCORCH_1')
		-- 	end 

		-- 	SetGameState('06_laura_cutscene_end', 'true')
		-- 	self.layer_cantelllo_scorch 		= createVideo({video = 'cantelllo_scorch', sound = 'cantelllo_scorch', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false})
		-- 	self:startCutScene(self.layer_cantelllo_scorch, on_end_cutscene, nil, '06_Cantello_CutScene')	
		-- else
		-- 	self:entityShow('area_link_09')
		-- end
		self:entityShow('area_link_08')
		self:entityShow('Layer_rope_trap')	
		self.timer:add( function()
			    	        completeGameTask('13')
				        end, 0)
		--self:entityHide('compositionloc_06_new_2')
		-- self:entityShow('compositionloc_06_new_2')
		-- self:getEntityNamed('compositionloc_06_new_2'):rewind(true)	
	end

	if isSceneVisited('09_Andreas_house') then 
		-- if not HasGameState('06_Cantelllo_scorch_02') then			
		-- 	local function on_end_cutscene_2()
		-- 		self:showBlackBar('BBT_06_CANTELLLO_SCORCH_2')
		-- 	end 
		-- 	SetGameState('06_Cantelllo_scorch_02', 'true')
		-- 	self.layer_cantelllo_scorch_2 		= createVideo({video = 'cantelllo_scorch_2', sound = 'cantelllo_scorch_2', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false})
		-- 	self:startCutScene(self.layer_cantelllo_scorch_2, on_end_cutscene_2, nil)	
		-- end
	end

	if isSceneVisited('09_Andreas_house') then
		self:entityHide('compositionloc_06_new_2')	
	end
		
	if HasGameState('06_laura_cutscene_end') then 
		self:entityShow('area_link_09')
		self:entityHide('area_link_09BBT') 
	end
	------------------------------------------------------------------------

	-- create zoom's -------------------------------------------------------
	self.zoom_Wall			= self:createZoomZone('Wall')
    self.zoom_Paper_Plane 	= self:createZoomZone('Paper_Plane')
    self.zoom_Gates			= self:createZoomZone('Gates')	
    self.zoom_Bench			= self:createZoomZone('Bench')	
	------------------------------------------------------------------------

	------------------------------------------------------------------------
	if IsToolFound('04_crowbar_button') then			
		local furry	 = createVideo({video = 'furry_idle', scale = 1, order = 7, x = 692, y = 443, isLooped = true, isAlpha = true})
		self.zg_furry = createVideo({video = 'zg_furry_idle', order = 1, scale = 2.0, x = 0, y = 0, sound = 'zg_furry_idle',
									 isLooped = true, isAlpha = false, parent = self.zoom_Gates:getEntityNamed('zg_bg')})
		furry:play()
	end
	------------------------------------------------------------------------

	-- main logic ----------------------------------------------------------
	do
		if isMiniGameCompleted('06_Wall') then
			self.zoom_Wall:closeAndDisable()
		end
	end
	------------------------------------------------------------------------	
end
------------------------------------------------------------------------

------------------------------------------------------------------------
function l_06_Town:FirstCutscene()
	self.timer:add(function()
    	    completeGameTask('07')

	    end, 0)
	
	if self.visited_first_time then
		local function on_end_cutscene()
            self:showBlackBar('BBT_06_MOLINARY_RAN_AWAY')
        end   
	    local video = createVideo({video = 'molinari_running', scale = 1.51, order = 1000, sound = 'molinari_running'})
	    SetGameState('06_molinari_running_end','true')
     	video.onFinish:add(function()
     
        	self:getEntityNamed('compositionBG'):setActive(true)       
        end)
        self:startCutScene(video, on_end_cutscene, nil, '06_Molinari_CutScene')
	else
		self:getEntityNamed('compositionBG'):setActive(true)	    
	end
end

------------------------------------------------------------------------

------------------------------------------------------------------------
function l_06_Town:focusOnLocationAndrea()
	local areaLinkAndrea = self:getEntityNamed( 'area_link_09' )

	self:setForcedObject( areaLinkAndrea )
--	self:getHint():setAdditionalHintObject( 'area_focus_andrea' )

	--self:entityShow( 'area_link_09' )

	self:focusOnObject(
		areaLinkAndrea,
		-30, 0, Vector2f( 1.4, 1 ), 0, true )
    
	local name_focus_object = 'fadeObject_'..tostring(fadeObjectCount)
	if self:hasEntityNamed(name_focus_object) then
		self:getEntityNamed(name_focus_object):setColor( Colorf(1, 1, 1, 0.7) )	
	end
end
------------------------------------------------------------------------

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

function l_06_Town:CreateLoaderTable()
	local objects =
	{
		{ name = 'bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/bg.jpg',  width = 1366,  height = 768,  },
		{ name = 'anchor_areas',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 200,  color = {r = 1, g = 1, b = 1, a = 0},  editingLocked = false,  treeItemIsExpanded = true,  width = 2,  height = 2,  },
		{ name = 'area_link_07',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 228,  y = 456,  order = 100,  scaleX = 1.2,  scaleY = 2.32,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_link_05',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 512,  y = 718,  order = 100,  scaleX = 11,  scaleY = 2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Wall',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 346,  y = 463,  order = 120,  scaleX = 1,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 70,  height = 70,  },
		{ name = 'area_zoom_Paper_Plane',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 745,  y = 604,  order = 120,  scaleX = 1.51,  scaleY = 1.2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_link_09',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 900,  y = 444,  order = 100,  scaleX = 1.51,  scaleY = 2.42,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_link_09BBT',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 900,  y = 444,  order = 101,  scaleX = 1.51,  scaleY = 2.42,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_link_08',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 145,  y = 231,  order = 100,  scaleX = 0.84,  scaleY = 1.8,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_link_10',  entityType = 'SpriteEntity',  parentName = 'anchor_areas',  x = 667,  y = 449.5,  order = 100,  isVisible = false,  isRespondable = false,  scaleX = 1.51,  scaleY = 2.42,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 58,  },
		{ name = '06_Town_Anim_Bg',  entityType = 'CompositionContainer',  x = -171,  y = 0,  order = 5,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/06_Town/Anim/06_Town_Anim_Bg.lua',  },
		{ name = 'compositionBG',  entityType = 'CompositionSequence',  parentName = '06_Town_Anim_Bg',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  isCyclic = true,  speed = 1,  },
		{ name = 'Layer_Gate_opened',  entityType = 'SpriteEntity',  x = 525,  y = 511,  order = 20,  isVisible = false,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_Gate_opened.png',  width = 608,  height = 314,  },
		{ name = 'Layer_Gate_closed',  entityType = 'SpriteEntity',  x = 579,  y = 493,  order = 10,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_Gate_closed.png',  width = 494,  height = 272,  },
		{ name = 'area_zoom_Gates',  entityType = 'SpriteEntity',  x = 678,  y = 453,  order = 60,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 230,  height = 120,  },
		{ name = 'layer_poster',  entityType = 'SpriteEntity',  x = 338,  y = 448,  order = 7,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/layer_papper.png',  width = 42,  height = 45,  },
		{ name = 'Layer_hole',  entityType = 'SpriteEntity',  x = 341,  y = 443,  order = 6,  angle = -1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_hole.png',  width = 32,  height = 22,  },
		{ name = 'Layer_casket_2',  entityType = 'SpriteEntity',  parentName = 'Layer_hole',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_casket_2.png',  width = 32,  height = 22,  },
		{ name = 'Layer_rope_trap',  entityType = 'SpriteEntity',  x = 141,  y = 385,  order = 6,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_rope_trap.png',  width = 62,  height = 266,  },
		{ name = 'Layer_window_glow',  entityType = 'SpriteEntity',  parentName = 'Layer_rope_trap',  x = -114,  y = -192,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_window_glow.png',  width = 286,  height = 172,  },
		{ name = 'LayerwindowAndrea',  entityType = 'SpriteEntity',  x = 934,  y = 558,  order = 10,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/LayerwindowAndrea.png',  width = 60,  height = 60,  },
		{ name = 'Layer_plane',  entityType = 'SpriteEntity',  x = 741,  y = 607,  order = 10,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_plane.png',  width = 72,  height = 48,  },
		{ name = 'area_zoom_Bench',  entityType = 'SpriteEntity',  x = 21,  y = 562,  order = 60,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 300,  height = 200,  },
		{ name = 'area_click_clock_4',  entityType = 'SpriteEntity',  x = 323,  y = 391,  order = 160,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 50,  height = 50,  },
		{ name = 'area_find_photo',  entityType = 'SpriteEntity',  x = 454,  y = 474,  order = 200,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 50, y = 50},  width = 100,  height = 100,  },
		{ name = 'clock_4',  entityType = 'SpriteEntity',  x = 325,  y = 395,  order = 6,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/clock_06_loc.png',  width = 36,  height = 48,  },
		{ name = 'cover_clock_4',  entityType = 'SpriteEntity',  x = 325,  y = 394,  order = 13,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/cover_clock_06_loc.png',  width = 32,  height = 42,  },
		{ name = 'fly_clock_4',  entityType = 'SpriteEntity',  x = 318.769,  y = 397.641,  order = 15,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/06_Town/Layers/fly_clock_4.png',  width = 250,  height = 250,  },
		{ name = '06_Town_Anim_Laura_in_door_Bg',  entityType = 'CompositionContainer',  x = -171,  y = 0,  order = 6,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Scripts/Scenes/06_Town/Anim/06_Town_Anim_Laura_in_door_Bg.lua',  },
		{ name = 'compositionloc_06_bg',  entityType = 'CompositionSequence',  parentName = '06_Town_Anim_Laura_in_door_Bg',  x = 0,  y = 0,  order = 10,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'compositionloc_06_new',  entityType = 'CompositionSequence',  parentName = '06_Town_Anim_Laura_in_door_Bg',  x = 0,  y = 0,  order = 5,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  speed = 1,  },
		{ name = 'compositionloc_06_new_2',  entityType = 'CompositionSequence',  parentName = '06_Town_Anim_Laura_in_door_Bg',  x = 0,  y = 0,  order = 7,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = false,  speed = 1,  },
		{ name = 'Layer_manul',  entityType = 'SpriteEntity',  x = 14.7521,  y = 625.309,  order = 8,  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 28.5, y = 33},  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_manul.png',  width = 57,  height = 66,  },
		{ name = 'Cover_maunl',  entityType = 'SpriteEntity',  x = 23,  y = 623,  order = 9,  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 45, y = 56},  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Cover_maunl.png',  width = 90,  height = 112,  },
		{ name = 'bbt_06_vortex',  entityType = 'SpriteEntity',  x = 737,  y = 146.5,  order = 30,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 254, y = 138.5},  width = 508,  height = 277,  },
		{ name = 'area_bbt_cantello_shop',  entityType = 'SpriteEntity',  x = 431,  y = 363,  order = 20,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 50, y = 50},  width = 100,  height = 100,  },
		{ name = 'Layer_cover_handle',  entityType = 'SpriteEntity',  x = 42.8099,  y = 580.106,  order = 10,  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 125, y = 35},  texturePath = 'Data/Textures/Scenes/06_Town/Layers/Layer_cover_handle.png',  width = 250,  height = 70,  },
	}
	return objects
end
