class 'l_03_Panorama_Z_Time_spiral' (ZoomZone)

function l_03_Panorama_Z_Time_spiral:__init(name, mode, PlayField)
	ZoomZone.__init(self, name, mode, PlayField)
	
	self:entityHide('area_click_zt_open_lock_1', 'area_click_zt_open_lock_2', 'area_click_zt_open_lock_3')
	
	self:entityHide('zt_symbol_1', 'zt_symbol_2', 'zt_symbol_3')
	
	self:registerBBT('area_bbt_zt_lock', 'BBT_03_LOCK')
	self:registerBBT('area_BBT_Radio_in_moss', 'BBT_03_MOSS')
	
	
	
	if not IsToolApplied('01_bulb_lamp') then
	    self:entityHide('area_apply_zt_phone')
	else
	    self:entityHide('area_bbt_zt_lock')
	end

	
	local function on_click_apply_zt_phone(e)
	    self:entityHide(e.target)
	    self:entityShow('area_click_zt_open_lock_1')
	    self:entityShow('area_click_zt_open_lock_2')
	    self:entityShow('area_click_zt_open_lock_3')
	    
	    if not e.save then
	    	self:playSound('03_apply_zt_phone')
	        self.playfield.zoom_comics_father_2:open()
	    end
	end
	self:registerActiveObject('area_apply_zt_phone', on_click_apply_zt_phone, false, 'CursorCamera')
	
	local counter = 3
	local function decrease_lock_counter(save)
	    counter = counter - 1
	    
	    if counter > 0 then
	        return
	    end
	    
	    self.timer:add(function()
    	        completeGameTask('05')
	        end, 0)
	
	    self.playfield:entityShow('area_link_04')
	    
	    self.playfield:entityHide('stone_1','stone_1_shadow','area_zoom_Time_spiral')
	    SetGameState('Time_spiral_was_destroed','true')
	    if not save then	
	    	do -- анимация камня
	    		dofile('Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Z_Time_spiral_Animation.lua')
				local time_spiral = createCompositionTimeSpiral() 		
			    time_spiral:attachTo(self:getEntityNamed('zt_bg'))
			    time_spiral:setXY(-320,  -240)
			    time_spiral:setOrder(22)
		    	self.mouseBlocker:push()
		    	self:playSound('03_stone_light')
		    	    

			 --    dofile('Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_Time_spiral_Animation.lua')
				-- local bg_time_spiral = createCompositionBgTimespiral() 		
	 
		        local function on_end_cutscene()
		        	self.mouseBlocker:pop()
	    			self.playfield.paralax_blocked = false

	    			completeGameTask('08')

		 			do -- анимация стекла 
		 				dofile('Data/Scripts/Scenes/03_Panorama/Animations/03_Panorama_Bg_Glass_Animation.lua')
						local bg_glass_1 = createComposition1()
						local bg_glass_2 = createCompositionWaves_radar_nachalo()		
					    bg_glass_1:attachTo(self.playfield:getEntityNamed('anchor_plane_2'))
					    bg_glass_1:setXY(-171,  0)
					    bg_glass_1:setOrder(22)
					    bg_glass_2:attachTo(self.playfield:getEntityNamed('anchor_plane_2'))
					    bg_glass_2:setXY(-171,  0)
					    bg_glass_2:setOrder(22)
					   
					    bg_glass_1.onFinish:add(function() 
					    	self.playfield:getEntityNamed('bg_radar_anim'):ChangeOpacity(1,0,0.7)
					    	self.playfield:getEntityNamed('bg_sky_anim'):ChangeOpacity(1,0,0.7)
					    end)
		 			end	    		
		        end 

		    	time_spiral.onFinish:add(function() 

			       	local time_spiral_crash_cut_scene  = createVideo({video = 'time_spiral_crash_cut_scene', sound = 'time_spiral_crash_cut_scene', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false})
        			self.playfield:startCutScene(time_spiral_crash_cut_scene, on_end_cutscene, nil)
	    			self:closeAndDisable()
		    	   	self.playfield.paralax_blocked = true

		    	   	local subtitles_1 = nil
					subtitles_1 = Subtitles(current_scene:getPanel())
					subtitles_1:pushReplic('SUB_03_FURY_SPEAK_1_1', 6, 4, true)
					subtitles_1:pushReplic('SUB_03_FURY_SPEAK_1_2', 11, 7, true)

					subtitles_1:play()
					time_spiral_crash_cut_scene.onFinish:add( function()
					                                subtitles_1:destroy()                                 
					                            end)				
		    	end) 
 			end 
	    else
	    	self.playfield:getEntityNamed('bg_radar_anim'):hide()
	    	self.playfield:getEntityNamed('bg_sky_anim'):hide()
	   	--	self.playfield:getEntityNamed('stone_2'):setVisible(true)

	   		self.timer:add( function()
	   							completeGameTask('08')
	   						end, 0)
	        self:closeAndDisable()
	    end
	end
	
	local function on_click_zt_open_lock(e)
	    self:entityHide(e.target)
	    
	    local i = string.sub(e.target, -1)
	    if not e.save then
	    		self:stopSound('03_click_stone_bird')
	        	self:playSound('03_click_stone_bird')
		        self:entityFadeShow('zt_symbol_'..i)
		        self.playfield:entityFadeShow('stone_symbol_'..i)

	    else
	        self:entityShow('zt_symbol_'..i)
	        self.playfield:entityShow('stone_symbol_'..i)
	    end
	    
	    decrease_lock_counter(e.save)
	end
	
	self:registerActiveObject('area_click_zt_open_lock_1', on_click_zt_open_lock)
	self:registerActiveObject('area_click_zt_open_lock_2', on_click_zt_open_lock)
	self:registerActiveObject('area_click_zt_open_lock_3', on_click_zt_open_lock)
end

function l_03_Panorama_Z_Time_spiral:onOpen()
    addGameTask('05')
end

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

function l_03_Panorama_Z_Time_spiral:CreateLoaderTable()
	local objects =
	{
		{ name = 'zt_bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Z_Time_spiral/zt_bg.jpg',  width = 640,  height = 480,  },
		{ name = 'zt_symbol_1',  entityType = 'SpriteEntity',  x = 252.5,  y = 252,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Z_Time_spiral/zt_symbol_1.png',  width = 93,  height = 112,  },
		{ name = 'zt_symbol_2',  entityType = 'SpriteEntity',  x = 602,  y = 253,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Z_Time_spiral/zt_symbol_2.png',  width = 150,  height = 148,  },
		{ name = 'zt_symbol_3',  entityType = 'SpriteEntity',  x = 729.5,  y = 504,  order = 0,  isRespondable = true,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/03_Panorama/Z_Time_spiral/zt_symbol_3.png',  width = 99,  height = 138,  },
		{ name = 'area_apply_zt_phone',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 100,  isRespondable = true,  scaleX = 6.4,  scaleY = 4.8,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_bbt_zt_lock',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 100,  isRespondable = true,  scaleX = 6.4,  scaleY = 4.8,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_click_zt_open_lock_1',  entityType = 'SpriteEntity',  x = 242,  y = 252,  order = 100,  isRespondable = true,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_click_zt_open_lock_2',  entityType = 'SpriteEntity',  x = 596,  y = 253,  order = 100,  isRespondable = true,  scaleX = 1.2,  scaleY = 1.1,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_click_zt_open_lock_3',  entityType = 'SpriteEntity',  x = 733,  y = 490,  order = 100,  isRespondable = true,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
	}
	return objects
end
