class 'l_03_Panorama' (PlayField)

local paralax_full_shift_time = 1
local paralax_planes_max_shift 	= {}
if IS_PARALAX_MODE then
	paralax_planes_max_shift 		= {90, 40, 10, 0}
else
	paralax_planes_max_shift 		= {0, 0, 0, 0}
end

function l_03_Panorama:__init(game_scene, name, path)
	PlayField.__init(self, game_scene, name, path)	
	
	self:linkScene('area_link_02',   'CursorDown',    '02_Mountain_path')
	self:linkScene('area_link_04',   'CursorUp',    '04_Gazebo')
	
	self.timer:add(function()
    	    completeGameTask('04')
	    end, 0)
	
	self:entityHide('area_link_04','area_zoom_Radio','area_zoom_Time_spiral')	
	self:entityHide('stone_symbol_1', 'stone_symbol_2', 'stone_symbol_3','door_open', 'lamp')    

    self:registerBBT('bbt_03_vortex', 'BBT_03_VORTEX')

   	-- cutscene -------------------------------------------------------------
	do
	   	local function on_click_start_cutscene(e)
		    self:entityHide(e.target)

		    addGameTask('08')

		    if not HasGameState('Time_spiral_was_destroed','true') then
		    	self:entityShow('area_zoom_Time_spiral')
		    end
		    if not e.save then
		    	self.moss_cut_scene  = createVideo({video = 'moss_cut_scene', sound = 'moss_cut_scene', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false})
	        	self:startCutScene(self.moss_cut_scene , nil, nil)
		    else
		    end
		    self:close()
		    
		    self:entityHide('moh01','moh02','moh03','moh04','area_BBT_Radio_in_moss')
		    self:entityShow('area_zoom_Radio')
		end
		self:registerActiveObject('area_click_start_cutscene', on_click_start_cutscene, false)
	end
	--------------------------------------------------------------------------
	
    self.zoom_comics_father_1 = self:createZoomZone('Comics_Father_1', ZOOM_TYPE_VIDEO_CALL)
    self.zoom_comics_father_2 = self:createZoomZone('Comics_Father_2', ZOOM_TYPE_VIDEO_CALL)
    self.zoom_radio = self:createZoomZone('Radio')    						
    self.zoom_time_spiral = self:createZoomZone('Time_spiral')


	-- bbt on waterfall ------------------------------------------------------
	do
		self:registerBBT('area_click_bbt_cant_drink', 'BBT_03_CLICK_WATERFALL')
	end
	--------------------------------------------------------------------------


	do  -- find clock -----------------------------------------------------   
	    if not self:isObjectClicked('area_click_clock_2') then
	    	self:getEntityNamed('area_click_clock_3'):hide()
			self.timer:add( function() 
			                  self:fadeGhostClock('clock_3', 'cover_clock_3', 'area_click_clock_3')
			                end, 35)   
	    end
	
        function on_click(event)
           	self:entityHide('clock_3')
            self:entityHide('area_click_clock_3')
            if not event.save then  
                self:entityFadeHide('cover_clock_3') 
            else 
                self:entityHide('cover_clock_3') 
            end
	    end
	    self:registerFindClockObject('area_click_clock_3', 'fly_clock_3', 'clock_3', on_click)
	end

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

    if IS_PARALAX_MODE then    
	    self.anchor_planes = {}
	    for i = 1,#paralax_planes_max_shift do
	        self.anchor_planes[i] = self:getEntityNamed('anchor_plane_'..i)
	    end
	    self:getMainEntity().onUpdate:add(function(obj,dt)
			    self:onUpdate(dt)
		    end)
   	end   
 --   	do
	-- 	local function on_click(event) 
 --            if event.save then
 --                self:entityHide('clock_3')
 --            end    
 --        end
 --    self:registerFindClockObject('area_click_clock_3', 'clock_3', 'clock_3', on_click)
	-- end
   

 --    local moveStoneEff = self:createPhoneCallEffector()

	-- phoneEffector:attachTo(self:getEntityNamed('Layer_phone_on'))	
	
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function l_03_Panorama:onUpdate(dt)
	if IS_PARALAX_MODE then
	    if self.active_zones:GetTop() or self.hidden_zoom_zones.zones:GetTop() or self.paralax_blocked then
	        return
	    end

	    local mouse_pos = GetCursorEntity():getScrPosition()
	    
	    local plane_shift_proportion = -(mouse_pos.x-WSCR_W/2)/WSCR_W
	    
	    for i =1,#paralax_planes_max_shift do
	        local target_plane_x = plane_shift_proportion * paralax_planes_max_shift[i]
	        local current_plane_x = self.anchor_planes[i]:getX()
	        local target_time = math.abs(current_plane_x - target_plane_x)/(2*paralax_planes_max_shift[i])
	        local new_plane_x = dt<target_time and current_plane_x + ((target_plane_x - current_plane_x)*dt/target_time) or target_plane_x
	        self.anchor_planes[i]:setX(new_plane_x)
	    end
	end
end
--------------------------------------------------------------------------------
  
--------------------------------------------------------------------------------
--                      GENERATED CONTENT. DO NOT EDIT.                       --
--------------------------------------------------------------------------------

function l_03_Panorama:CreateLoaderTable()
	local objects =
	{
		{ name = 'bbt_03_vortex',  entityType = 'SpriteEntity',  x = 781,  y = 123,  order = 60,  isVisible = false,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 225, y = 105},  width = 450,  height = 210,  },
		{ name = 'bg',  entityType = 'SpriteEntity',  x = 503,  y = 373,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/bg.jpg',  width = 1366,  height = 768,  },
		{ name = 'area_zoom_Comics_Father_1',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  isVisible = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_link_02',  entityType = 'SpriteEntity',  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_Comics_Father_2',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  isVisible = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'anchor_plane_1',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 30,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'bush_1',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_1',  x = 1093,  y = 605,  order = 30,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/bush_1.png',  width = 302,  height = 326,  },
		{ name = 'bush_2',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_1',  x = 13,  y = 598,  order = 30,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/bush_2.png',  width = 470,  height = 340,  },
		{ name = '03_Panorama_Bg_layer_5_Animation',  entityType = 'CompositionContainer',  parentName = 'anchor_plane_1',  x = -171,  y = 0,  order = 40,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_layer_5_Animation.lua',  },
		{ name = 'composition5',  entityType = 'CompositionSequence',  parentName = '03_Panorama_Bg_layer_5_Animation',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  isCyclic = true,  speed = 1,  },
		{ name = 'anchor_plane_2',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 20,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'front_bg',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 504,  y = 518,  order = 16,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/front_bg.png',  width = 1452,  height = 502,  },
		{ name = 'stone_1_shadow',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 336,  y = 391,  order = 20,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/stone_1_shadow.png',  width = 950,  height = 768,  },
		{ name = 'stone_1',  entityType = 'SpriteEntity',  parentName = 'stone_1_shadow',  x = -7,  y = -7,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/stone_1.png',  width = 950,  height = 768,  },
		{ name = 'stone_symbol_1',  entityType = 'SpriteEntity',  parentName = 'stone_1',  x = -30,  y = -78,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/stone_symbol_1.png',  width = 40,  height = 46,  },
		{ name = 'stone_symbol_2',  entityType = 'SpriteEntity',  parentName = 'stone_1',  x = 121,  y = -70.5,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/stone_symbol_2.png',  width = 56,  height = 69,  },
		{ name = 'stone_symbol_3',  entityType = 'SpriteEntity',  parentName = 'stone_1',  x = 174.5,  y = 29.5,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/stone_symbol_3.png',  width = 39,  height = 49,  },
		{ name = 'door_open',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 816,  y = 455,  order = 20,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/door_open.png',  width = 172,  height = 176,  },
		{ name = 'lamp',  entityType = 'SpriteEntity',  parentName = 'door_open',  x = 37,  y = -38,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/lamp.png',  width = 18,  height = 32,  },
		{ name = 'broken_lamp',  entityType = 'SpriteEntity',  parentName = 'door_open',  x = 37,  y = -38,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/broken_lamp.png',  width = 18,  height = 32,  },
		{ name = 'area_zoom_Time_spiral',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 379,  y = 370,  order = 110,  scale = 3,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Radio',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 870,  y = 463,  order = 100,  scaleX = 2.8,  scaleY = 3,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_link_04',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 347,  y = 234,  order = 100,  angle = -10,  scaleX = 4,  scaleY = 6,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'cover_clock_3',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 341,  y = 629,  order = 30,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/cover_clock_3.png',  width = 58,  height = 40,  },
		{ name = 'clock_3',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 344,  y = 626,  order = 25,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/clock_03_loc.png',  width = 62,  height = 50,  },
		{ name = 'fly_clock_3',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 347,  y = 603,  order = 36,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/fly_clock_3.png',  width = 250,  height = 250,  },
		{ name = '03_Panorama_Bg_layer_4_Animation',  entityType = 'CompositionContainer',  parentName = 'anchor_plane_2',  x = -171,  y = 0,  order = 18,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_layer_4_Animation.lua',  },
		{ name = 'composition4',  entityType = 'CompositionSequence',  parentName = '03_Panorama_Bg_layer_4_Animation',  x = 1,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'moh04',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 850,  y = 472,  order = 20,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/moh04.png',  width = 116,  height = 134,  },
		{ name = 'moh03',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 898,  y = 502,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/moh03.png',  width = 64,  height = 68,  },
		{ name = 'moh02',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 943,  y = 465,  order = 20,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/moh02.png',  width = 98,  height = 166,  },
		{ name = 'moh01',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 891,  y = 385,  order = 20,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/moh01.png',  width = 140,  height = 62,  },
		{ name = 'area_click_start_cutscene',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_2',  x = 379,  y = 370,  order = 110,  scale = 3,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'anchor_plane_3',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 10,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'middle_bg',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_3',  x = 203,  y = 293,  order = 15,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/middle_bg.png',  width = 848,  height = 580,  },
		{ name = '03_Panorama_Bg_layer_3_Animation',  entityType = 'CompositionContainer',  parentName = 'anchor_plane_3',  x = -171,  y = 0,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_layer_3_Animation.lua',  },
		{ name = 'composition3',  entityType = 'CompositionSequence',  parentName = '03_Panorama_Bg_layer_3_Animation',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'anchor_plane_4',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'sky',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_4',  x = 512,  y = 249,  order = 5,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/sky.png',  width = 1366,  height = 498,  },
		{ name = 'storm',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_4',  x = 739,  y = 303,  order = 10,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/storm.png',  width = 124,  height = 214,  },
		{ name = 'back_bg',  entityType = 'SpriteEntity',  parentName = 'anchor_plane_4',  x = 902,  y = 346,  order = 14,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Layers/back_bg.png',  width = 662,  height = 378,  },
		{ name = '03_Panorama_Bg_layer_1_Animation',  entityType = 'CompositionContainer',  parentName = 'anchor_plane_4',  x = -171,  y = 0,  order = 20,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_layer_1_Animation.lua',  },
		{ name = 'composition1',  entityType = 'CompositionSequence',  parentName = '03_Panorama_Bg_layer_1_Animation',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  isCyclic = true,  speed = 1,  },
		{ name = '03_Panorama_Bg_layer_2_Animation',  entityType = 'CompositionContainer',  parentName = 'anchor_plane_4',  x = -174,  y = 0,  order = 25,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_layer_2_Animation.lua',  },
		{ name = 'composition2',  entityType = 'CompositionSequence',  parentName = '03_Panorama_Bg_layer_2_Animation',  x = -1,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  isCyclic = true,  speed = 1,  },
		{ name = 'area_find_photo',  entityType = 'SpriteEntity',  x = 74,  y = 368,  order = 200,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_BBT_Radio_in_moss',  entityType = 'SpriteEntity',  x = 870,  y = 463,  order = 101,  scaleX = 2.8,  scaleY = 3,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_click_clock_3',  entityType = 'SpriteEntity',  x = 341,  y = 634,  order = 101,  color = {r = 1, g = 1, b = 1, a = 0.0431373},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_click_bbt_cant_drink',  entityType = 'SpriteEntity',  x = 94,  y = 497,  order = 200,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 175,  height = 90,  },
	}
	return objects
end
