class 'l_01_Boat_crash_site' (PlayField)

-- deprecated paralax =( ---------------------------------------------------
local paralax_full_shift_time = 1
local paralax_planes_max_shift = {90, 40, 10, 0}
----------------------------------------------------------------------------

function l_01_Boat_crash_site:__init(game_scene, name, path)
    PlayField.__init(self, game_scene, name, path)

    -- varibles of bg animation ------------------------------------------------
    -- r net -------------------------------------------------------------------
    self.net_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('cetka_B_Molnia2')
    self.net_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('setka_N')
    self.net_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('cetka_B_Molnia2')
    self.net_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('setka_N')
    ----------------------------------------------------------------------------

    -- stones under net --------------------------------------------------------
    self.stones_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('stones_moln')
    self.stones_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('stones')
    self.stones_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('stones_moln')
    self.stones_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('stones')
    self.stones_bg =  self:getEntityNamed('compositionBG3'):getElementByName('stones')
    ----------------------------------------------------------------------------

    -- l net ang l box --------------------------------------------------------
    self.l_net_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('1cetka_B_Molnia2')
    self.l_net_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('setka')
    self.l_net_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('1cetka_B_Molnia2')
    self.l_net_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('setka')
    ----------------------------------------------------------------------------

    ----------------------------------------------------------------------------
    self.l_box_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('jashik_2_M2')
    self.l_box_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('jashik_2')
    self.l_box_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('jashik_2_M2')
    self.l_box_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('jashik_2')
    ----------------------------------------------------------------------------

    -- box in water --------------------------------------------------------
    self.w_box_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('jashik_1_M2')
    self.w_box_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('jashik_1')
    self.w_box_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('jashik_1_M2')
    self.w_box_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('jashik_1')
    ----------------------------------------------------------------------------

    -- box near zaval ----------------------------------------------------------
    self.z_box_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('jashik_3')
    self.z_box_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('jashik_3')
    ----------------------------------------------------------------------------

    -- zaval --------------------------------------------------------
    self.zaval_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('zaval_Molnia2')
    self.zaval_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('zaval')
    self.zaval_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('zaval_Molnia2')
    self.zaval_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('zaval')
    ----------------------------------------------------------------------------

    -- harpoon -----------------------------------------------------------------
    self.harpoon_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('garpyn_Moln')
    self.harpoon_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('garpyn')
    self.harpoon_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('garpyn_Moln')
    self.harpoon_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('garpyn')
    self.harpoon_bg =  self:getEntityNamed('compositionBG3'):getElementByName('garpyn')
    ----------------------------------------------------------------------------

    -- rope --------------------------------------------------------------------
    self.rope_moln_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('rope_moln')
    self.rope_1 =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('rope')
    self.rope_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('rope_moln')
    self.rope_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('rope')
    self.rope_bg =  self:getEntityNamed('compositionBG3'):getElementByName('rope')
    ----------------------------------------------------------------------------

    -- nakladka ----------------------------------------------------------------
    self.nakladka_na_lodku_bg =  self:getEntityNamed('compositionBG3'):getElementByName('nakladka_na_lodku')
    ----------------------------------------------------------------------------

    -- box interactive --------------------------------------------------------- 
    self.boxes_intrctv1_moln =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('boxes_intrctv1')
    self.boxes_intrctv2_moln =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('boxes_intrctv2')
    self.boxes_intrctv3_moln =  self:getEntityNamed('compositionMolniya'):getElementByName('m1'):getElementByName('boxes_intrctv3')
    self.boxes_intrctv1_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('boxes_intrctv1')
    self.boxes_intrctv2_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('boxes_intrctv2')
    self.boxes_intrctv3_moln_2 =  self:getEntityNamed('compositionMolniya2'):getElementByName('m2'):getElementByName('boxes_intrctv3')
    ----------------------------------------------------------------------------

    -- interactive help --------------------------------------------------------
    self.tutorial = self:getGameScene():getTutorial() 
    ----------------------------------------------------------------------------   

    ----------------------------------------------------------------------------
    self:entityHide('area_apply_dog','area_find_note_1','area_find_note_2','area_find_pliers_01')   
    self:entityHide('blockage', 'net_after', 'pit_2', 'box_2', 'box_3', 'bag_1','bag_2','pliers','document','box_intrctv_2')
    ---------------------------------------------------------------------------- 

       -- hides textures from anim bg ---------------------------------------------
    -- stones under net --------------------------------------------------------
    self.stones_moln_1:setOpacity(0)
    self.stones_1:setOpacity(0)
    self.stones_moln_2:setOpacity(0)
    self.stones_2:setOpacity(0)
    self.stones_bg:setOpacity(0)

    self:entityHide('pit_1')
    ----------------------------------------------------------------------------

    -- left net and box --------------------------------------------------------
    self.l_net_moln_1:setOpacity(0)
    self.l_net_1:setOpacity(0)
    self.l_net_moln_2:setOpacity(0)
    self.l_net_2:setOpacity(0)
    ----------------------------------------------------------------------------

    ----------------------------------------------------------------------------
    self.l_box_moln_1:setOpacity(0)
    self.l_box_1:setOpacity(0)
    self.l_box_moln_2:setOpacity(0)
    self.l_box_2:setOpacity(0)
    ----------------------------------------------------------------------------

    -- box near crash ----------------------------------------------------------
    self.z_box_1:setOpacity(0)
    self.z_box_2:setOpacity(0)
    ----------------------------------------------------------------------------

    -- crash -------------------------------------------------------------------
    self.zaval_moln_1:setOpacity(0)
    self.zaval_1:setOpacity(0)
    self.zaval_moln_2:setOpacity(0)
    self.zaval_2:setOpacity(0)
    ----------------------------------------------------------------------------

    -- box interactive --------------------------------------------------------- 
    self.boxes_intrctv2_moln:setOpacity(0)
    self.boxes_intrctv2_moln_2:setOpacity(0)
    self.boxes_intrctv3_moln:setOpacity(0)
    self.boxes_intrctv3_moln_2:setOpacity(0)
    ---------------------------------------------------------------------------- 

    -- links -------------------------------------------------------------------
    self:linkScene('area_link_02',   'CursorUp',    '02_Mountain_path') 
    self:entityHide('area_link_02') 
    
    self.zoom_box           = self:createZoomZone('Box')    
    self.zoom_fishing_net   = self:createZoomZone('Fishing_net')  
    self.zoom_road_block    = self:createZoomZone('Road_block')    
    self.zoom_yacht         = self:createZoomZone('Yacht')
    ----------------------------------------------------------------------------    
   

    -- fist start -------------------------------------------------------------- 
    if self:isFirstVisited() then
        self:blackWindow()
    else
        addGameTask('01')
        addGameTask('02')

        self.timer:add( function()
                            self:splashBlink() 
                        end, 3)
        
        if not self:isObjectClicked('area_click_molinari', self.name) then
            self:setForcedObject(self:getEntityNamed('area_click_molinari'))
        end    
        self:getPanel():getControlsPanel():getEntityNamed('bttn_phone'):show()
    end
    -----------------------------------------------------------------------

    -- bbt vortext --------------------------------------------------------
    do
        self:registerBBT('bbt_01_vortex', 'BBT_01_VORTEX')
    end
    -----------------------------------------------------------------------
    
    -- find clock ---------------------------------------------------------
    do    
        if not self:isObjectClicked('area_click_clock_1') then
            self:getEntityNamed('area_click_clock_1'):hide()
            self.timer:add( function() 
                                self:fadeGhostClock('clock_1', 'conch', 'area_click_clock_1')
                            end, 40)   
        end

        function on_click(event)
            self:entityHide('area_click_clock_1','clock_1')

            if not event.save then  
                self:entityFadeHide('conch') 
            else 
                self:entityHide('conch') 
            end
        end

        function on_fly_end(event)           
            if not event.save then 
                local bttn_clock = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_clock')
                bttn_clock:setActive(false)
                bttn_clock:setPressed(false) 

                self.mouseBlocker:push()
                self.timer:add( function()
                                    self.mouseBlocker:pop()                                   
                                    self:hideInfromScreen()
                                    current_scene:getTutorial():showTip( 'HINT', 0 )    
                                    bttn_clock:setActive(true)                                       
                                end, 2.0)              
            end
        end
        self:registerFindClockObject('area_click_clock_1', 'fly_clock_1', 'clock_1', on_click, on_fly_end)
    end
    ------------------------------------------------------------------------   

    -- find photo ----------------------------------------------------------
    do
        local function on_take_photo(event)   
            if not event.save then
                local bttn_clock = current_scene:getPanel():getControlsPanel():getEntityNamed('bttn_clock')
                bttn_clock:setActive(false)
                bttn_clock:setPressed(false)  

                self.mouseBlocker:push()
                self.timer:add( function()
                                    self.mouseBlocker:pop()
                                    current_scene:getTutorial():showTip( 'CLOCK_CLICK', 0 )
                                    self:hideInfromScreen()
                                    bttn_clock:setActive(true) 
                                end, 4.0)
            end
        end  

        self:registerFindFlyPhoto('area_find_photo', '01_GrandFather', on_take_photo) 
    end
    -----------------------------------------------------------------------

    -- planes help --------------------------------------------------------
    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)

    self.prevMousePos = {}
    ----------------------------------------------------------------------------   

    -- dog runnning -------------------------------------------------------------
    do
        if IsToolFound('02_sabre') and not HasGameState('02_SABLE_WAS_FOUND') then
            SetGameState('02_SABLE_WAS_FOUND', 'true')

            self.dog_find = createVideo({video = 'dog_loc1_nose_running', order = 150, x = 798, y = 615, isLooped = false, isAlpha = true})
            self:startCutScene(self.dog_find , open_zom_box, 5)
            self:playSound('dog_loc1_nose_running')

            self.timer:add( function()
                                 self.dog_find:hide()
                            end, 5)
        end
    end
    ----------------------------------------------------------------------------
	
    -- molinary comics ---------------------------------------------------------
    do    
    	local function on_click_molinari(e)
    	    self:entityHide(e.target)	    
    	    self:setForcedObject(nil)	
    	    self:entityHide('molinari_1')

    	    if not e.save then
    	        local molinari_comics = self:createComics('Molinari')
                molinari_comics:getFrame(1):setAutoCompleteFrame(true)

                molinari_comics.on_finish = function()
                    self:addNote('Note_01_Molinari')
                    addGameTask('03') 

                    local function on_end()
                        self.mouseBlocker:push()
                        self.timer:add( function() 

                                            self.mouseBlocker:pop()
                                            self:askInteractiveHelp() 
                                        end, 0.5 )   
                    end 

                    local function on_molinary_ran_away()
                        self:showBlackBar('BBT_01_MOLINARY_RAN_AWAY')

                        self.timer:add( function()
                                            self:hideBlackBar()
                                        end, 3.0)
                    end  

                    local video = createVideo({video = 'molinari_running', scale = 1.51, order = 1000, sound = '01_Molinari_running'})                 
                    video.onFinish:add( on_end )

                    self:startCutScene(video, on_molinary_ran_away, nil, '01_Molinari_CutScene')

                    local subtitles = Subtitles(self:getPanel():getControlsPanel())
                    subtitles:pushReplic('SUB_01_MOLINARI', 0.5, 3, true)
                    subtitles:play()
            
                    self:entityShow('blockage')
                    self.zaval_moln_1:setOpacity(1)
                    self.zaval_1:setOpacity(1)
                    self.zaval_moln_2:setOpacity(1)
                    self.zaval_2:setOpacity(1)
                end

                molinari_comics:start()
            else
                self:addNote('Note_01_Molinari')
                addGameTask('03')

                 self.timer:add( function() 
                                     self:askInteractiveHelp() 
                                 end, 0 )   
            
                self:entityShow('blockage')
                self.zaval_moln_1:setOpacity(1)
                self.zaval_1:setOpacity(1)
                self.zaval_moln_2:setOpacity(1)
                self.zaval_2:setOpacity(1)
    	    end
    	end
    	self:registerActiveObject('area_click_molinari', on_click_molinari, false, 'CursorDialog')
    end
	----------------------------------------------------------------------------

    -- click bag ------------------------------------------------------------------
    do
        local function onClickBag(e)
             self:entityHide(e.target)
             self:entityShow('area_find_note_1')
            if not e.save then
                self:entityFadeHide('bag')
                self:entityFadeShow('bag_2','document','pliers')
                self:playSound('01_click_bag')
            else
                self:entityHide('bag')
                self:entityShow('bag_2','document','pliers')
            end

        end 
        self:registerActiveObject('area_click_bag', onClickBag, false)
    end
    -------------------------------------------------------------------------------

    -- find notes -----------------------------------------------------------------
    do
        local function on_find_note_1(event)
            self:entityHide(event.target, 'document')
            self:entityShow('area_find_note_2')

            self:addFlyNote('Note_01_Newspaper', event.save, 'Layer_01_Fly_Newspaper', true, self:getEntityNamed('area_find_note_1'), nil, Vector2f(0.5, 0.5), nil)
            
            if not event.save then
                self:entityFadeHide('document')           
            end            
        end
        self:registerActiveObject('area_find_note_1', on_find_note_1, false)

        local function on_find_note_2(event)   
            self:entityHide(event.target)
            self:entityShow('area_find_pliers_01')

            local function on_click_note(event)                
            end 
            self:addFlyNote('Note_01_Document', event.save, 'Layer_01_Fly_Document', true, self:getEntityNamed('area_find_note_2'), nil, Vector2f(0.5, 0.5),  on_click_note)  

            if not event.save then
                self:entityFadeHide('bag_2')   
                self:entityFadeShow('bag_1')            
            else
                self:entityHide('bag_2')   
                self:entityShow('bag_1')        
            end
        end
        self:registerActiveObject('area_find_note_2', on_find_note_2, false)

        local function on_find_pliers_01(e)
            self:entityHide(e.target)
            self:entityHide('pliers')
        end
        self:registerToolFindInfo('01_pliers', 'area_find_pliers_01', on_find_pliers_01)
    end
    -------------------------------------------------------------------------------
    
    -- apply dog ------------------------------------------------------------------
    do
        local function on_apply_dog(e)
            self:entityHide(e.target, 'pit_1')
                          
            self.stones_moln_1:setOpacity(0)
            self.stones_1:setOpacity(0)
            self.stones_moln_2:setOpacity(0)
            self.stones_2:setOpacity(0)
            self.stones_bg:setOpacity(0)
          
            self:getEntityNamed('pit_2'):setOrder(70)
            if not e.save then      
                self:entityFadeHide('pit_2')      
                self.stop_splash = true

                self.mouseBlocker:push()
                local dog_video = self:getEntityNamed('dog_digging')
                dog_video:setVisible(true)
                dog_video:setActive(true)

                self:playSound('01_Dog_digging')

                dog_video.onFinish:add(function()            
                        self.mouseBlocker:pop()

                        dog_video:setVisible(false)
                        dog_video:setActive(false)
                        self:entityShow('pit_2')
                       
                        self.stop_splash = false
                        self:findTool('01_wrench')
                    end)
            else
                self:entityShow('pit_2')         
                self:findTool('01_wrench')
            end
        end
        self:registerToolApplyInfo('dog', 'area_apply_dog', on_apply_dog, 'BBT_01_NEED_DOG')
    end
    --------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function l_01_Boat_crash_site:onUpdate(dt)
    if self.active_zones:GetTop() or self.hidden_zoom_zones.zones:GetTop() or self.paralax_blocked then
        return
    end
    local mouse_pos = GetCursorEntity():getScrPosition()

    if self.prevMousePos.x ~= mouse_pos.x or self.prevMousePos.x ~= mouse_pos.y then
    
        self.prevMousePos = mouse_pos
        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
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function l_01_Boat_crash_site:askInteractiveHelp()
    local function callback( agreed, save )
        if self.tutorial:isActive() then           
            if ( not self.tutorial:isTipShown( 'PHONE' ) ) then
                self.tutorial:showTip( 'PHONE', 0 )

            elseif ( not self.tutorial:isTipShown( 'PANEL_LOCK' ) ) then
                self.tutorial:showTip( 'PANEL_LOCK', 0 )  

            elseif ( not self.tutorial:isTipCompleted( 'PHOTO_CLICK' ) and 
                    not self:isObjectClicked('area_find_photo', self.name) ) then    
                 self.tutorial:showTip( 'PHOTO_CLICK', 0 )    

            elseif ( not self.tutorial:isTipCompleted( 'CLOCK_CLICK' ) and 
                    not self:isObjectClicked('area_click_clock_1', self.name) ) then    
                 self.tutorial:showTip( 'CLOCK_CLICK', 0 )   

            elseif ( not self.tutorial:isTipCompleted( 'HINT' ) ) then
                self.tutorial:showTip( 'HINT', 0 )     

            elseif ( not self.tutorial:isTipShown( 'ZOOM_ZONE' )) then
                self.tutorial:showTip( 'ZOOM_ZONE', 0 )

            elseif ( not self.tutorial:isTipShown( 'FIND_TOOL' )) then
                self.zoom_fishing_net:open()

            elseif ( not self.tutorial:isTipShown( 'APPLY_TOOL' ) 
                and HasGameState(TOOL_INFO_SHOWN, '01_pliers')
                and isZoomZoneVisited('Fishing_net', self:getName()) ) then
                self.zoom_fishing_net:open()     
            end           
        end
    end

    self.tutorial:showRequestDialog( callback )
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function l_01_Boat_crash_site:blackWindow()  
    local subtitles_1 = nil

    self.timer:add( function()
                        self:getPanel():setMode(EPanelMode.CLEAN)
                        current_scene:getInventory():dropTool()
                        current_scene:volumeTurnDownMusic()
                        current_scene:volumeTurnDownInternoise()

                        self:getMainEntity():setVisible(false)
                        self:getMainEntity():setRespondable(false)

                        subtitles_1 = Subtitles(current_scene:getPanel())
                        subtitles_1:pushReplic('SUB_01_AWAKE_1', 0, 7.5, true)
                        subtitles_1:pushReplic('SUB_01_AWAKE_2', 8, 6.5, true)
                        subtitles_1:pushReplic('SUB_01_AWAKE_3', 15, 5.5, true)
                        
                        subtitles_1:play()
                    end, 0)    

    local function on_end()      
        subtitles_1:destroy() 
        self:Awake()
        current_scene:getPanel():getEntityNamed('bttn_skip_intro1'):destroy()
    end    

    local video = createVideo({video = 'wakeup', sound = '01_awake', order = 150, x = 512, y = 384, isLooped = false, isAlpha = false, isDestroyOnEnd = true})
    video:attachTo( current_scene:getPanel():getMainEntity() )
    video:setOrder(100)
    video:setXY(512, 384)
    video:setScale(1.51)
    video:setLooped(false)
    video:setRespondable(true)

    video:play()
    self.wakeup_cutscene = video

    video.onFinish:add( on_end ) 

    local function on_skip_bttn_click()
        subtitles_1:destroy()
        video:stop()
        video:hide()        
        on_end() 

        current_scene:getPanel():getEntityNamed('bttn_skip_intro1'):destroy()
    end

    local bttn = CreateButtonEntity('Data/Textures/GUI/Buttons/bttn_skip.png')
    bttn:setName('bttn_skip_intro1')
    bttn:attachTo( current_scene:getPanel():getMainEntity() )
    bttn:setOrder(110)
    bttn:setXY(991, 24)
    bttn.onPress:add( on_skip_bttn_click )    
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
function l_01_Boat_crash_site:Awake()

      local function on_end_2()       
        if not self:isObjectClicked('area_click_molinari', self.name) then
            self:setForcedObject(self:getEntityNamed('area_click_molinari'))
        end
       
        self:getMainEntity():setVisible(true)
        self:getMainEntity():setRespondable(true)

        self.mouseBlocker:push()
        self.timer:add( function()
                            self.mouseBlocker:pop()

                            current_scene:volumeRestoreMusic()
                            current_scene:volumeRestoreInternoise()
                            self:getPanel():setMode(EPanelMode.QUEST)

                            self.timer:add( function()
                                                self:splashBlink() 
                                            end, 3)

                            self:getPanel():getControlsPanel():getEntityNamed('bttn_phone'):show()

                            addGameTask('01')
                            addGameTask('02')
                        end, 0.5)
    end 

    -- wakeup 2
    local video_2 = createVideo({video = 'wakeup_2', sound = '01_awake_2', scale = 1.51, order = 600, x = 512, y = 384, isLooped = false, isAlpha = false, isDestroyOnEnd = true})
    video_2:attachTo( current_scene:getPanel():getMainEntity() )
    video_2:play()
    video_2:setRespondable( true )

    video_2.onFinish:add( on_end_2 )   
end
--------------------------------------------------------------------------------  

--------------------------------------------------------------------------------
function l_01_Boat_crash_site:splashBlink() 
    local rand_time = math.random(7, 16)        
        
    local rand_ind = math.random(1, 2)

    if (not self.stop_splash) then
        local compositionName = nil
        if (rand_ind == 1) then
            self:playSound('01_splash_1')
            compositionName = 'compositionMolniya'
        else
            self:playSound('01_splash_2')
            compositionName = 'compositionMolniya2'
        end

        self:getEntityNamed(compositionName):play() 
    end 

    self.timer:add( function() 
                        self:splashBlink()
                    end, rand_time)   
end
--------------------------------------------------------------------------------

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

function l_01_Boat_crash_site:CreateLoaderTable()
	local objects =
	{
		{ name = 'bg',  entityType = 'SpriteEntity',  x = 512,  y = 384,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/bg.jpg',  width = 1366,  height = 768,  },
		{ name = 'bag',  entityType = 'SpriteEntity',  x = 337,  y = 579,  order = 65,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/bag.png',  width = 213,  height = 156,  },
		{ name = 'bag_1',  entityType = 'SpriteEntity',  x = 337,  y = 577,  order = 65,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/bag_1.png',  width = 213,  height = 156,  },
		{ name = 'bag_2',  entityType = 'SpriteEntity',  x = 336,  y = 578,  order = 65,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/bag_2.png',  width = 213,  height = 156,  },
		{ name = 'area_find_note_1',  entityType = 'SpriteEntity',  x = 356,  y = 547,  order = 75,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_find_note_2',  entityType = 'SpriteEntity',  x = 351,  y = 553,  order = 74,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 100,  height = 100,  },
		{ name = 'area_click_bag',  entityType = 'SpriteEntity',  x = 329,  y = 565,  order = 70,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 180,  height = 120,  },
		{ name = 'area_find_pliers_01',  entityType = 'SpriteEntity',  x = 264,  y = 561,  order = 71,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_apply_dog',  entityType = 'SpriteEntity',  x = 960,  y = 596,  order = 100,  scaleX = 1.5,  scaleY = 1,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Fishing_net',  entityType = 'SpriteEntity',  x = 938,  y = 547,  order = 101,  scaleX = 2,  scaleY = 2.5,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Yacht',  entityType = 'SpriteEntity',  x = 249,  y = 397,  order = 100,  scaleX = 2.2,  scaleY = 2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Road_block',  entityType = 'SpriteEntity',  x = 728,  y = 338,  order = 105,  scaleX = 2.5,  scaleY = 1.5,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_zoom_Box',  entityType = 'SpriteEntity',  x = 506,  y = 437,  order = 100,  scaleX = 3,  scaleY = 1.7,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_link_02',  entityType = 'SpriteEntity',  x = 729,  y = 301,  order = 105,  scaleX = 2.5,  scaleY = 2,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'area_click_molinari',  entityType = 'SpriteEntity',  x = 568,  y = 427,  order = 120,  scaleX = 3.8,  scaleY = 5.82,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'pit_1',  entityType = 'SpriteEntity',  x = 966,  y = 567,  order = 2,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/pit_1.png',  width = 160,  height = 146,  },
		{ name = 'net',  entityType = 'SpriteEntity',  x = 988,  y = 493,  order = 15,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/net.png',  width = 414,  height = 552,  },
		{ name = 'blockage',  entityType = 'SpriteEntity',  x = 717,  y = 345,  order = 30,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/blockage.png',  width = 218,  height = 194,  },
		{ name = 'box_1',  entityType = 'SpriteEntity',  x = 436,  y = 429,  order = 15,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/box_1.png',  width = 96,  height = 52,  },
		{ name = 'box_2',  entityType = 'SpriteEntity',  x = 592,  y = 459,  order = 20,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/box_2.png',  width = 142,  height = 108,  },
		{ name = 'box_3',  entityType = 'SpriteEntity',  x = 773,  y = 394,  order = 35,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/box_3.png',  width = 78,  height = 42,  },
		{ name = 'boxes',  entityType = 'SpriteEntity',  x = 763,  y = 370,  order = 55,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/boxes.png',  width = 118,  height = 86,  },
		{ name = 'net_after',  entityType = 'SpriteEntity',  x = 651,  y = 515,  order = 25,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/net_after.png',  width = 200,  height = 102,  },
		{ name = 'anchor_plane_1',  entityType = 'SpriteEntity',  x = 0,  y = 1,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 2,  height = 2,  },
		{ name = 'anchor_plane_2',  entityType = 'SpriteEntity',  x = 0,  y = 1,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 2,  height = 2,  },
		{ name = 'anchor_plane_3',  entityType = 'SpriteEntity',  x = 0,  y = 1,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 2,  height = 2,  },
		{ name = 'number_key_1',  entityType = 'SpriteEntity',  x = 997,  y = 550,  order = 65,  scale = 0.5,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/number_key_1.png',  width = 72,  height = 66,  },
		{ name = 'anchor_plane_4',  entityType = 'SpriteEntity',  x = 0,  y = 1,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 2,  height = 2,  },
		{ name = 'dog_digging',  entityType = 'VideoEntity',  x = 950,  y = 591,  order = 62,  isVisible = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/01_Boat_crash_site/dog_digging.webm',  hasAlpha = false,  isLooped = false,  fps = 24,  },
		{ name = 'pit_2',  entityType = 'SpriteEntity',  x = 966,  y = 567,  order = 2,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/pit_2.png',  width = 160,  height = 146,  },
		{ name = 'area_find_photo',  entityType = 'SpriteEntity',  x = 672,  y = 163,  order = 200,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'clock_1',  entityType = 'SpriteEntity',  x = 657,  y = 626,  order = 61,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/clock_1_loc.png',  width = 50,  height = 46,  },
		{ name = 'conch',  entityType = 'SpriteEntity',  x = 650,  y = 609,  order = 62,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/conch.png',  width = 72,  height = 70,  },
		{ name = 'area_click_clock_1',  entityType = 'SpriteEntity',  x = 658,  y = 605,  order = 160,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 100,  height = 100,  },
		{ name = 'document',  entityType = 'SpriteEntity',  x = 308,  y = 550,  order = 66,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/document.png',  width = 60,  height = 68,  },
		{ name = 'pliers',  entityType = 'SpriteEntity',  x = 287,  y = 564,  order = 67,  angle = -19,  scaleX = -1,  scaleY = 1,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/pliers3.png',  width = 56,  height = 52,  },
		{ name = 'fly_clock_1',  entityType = 'SpriteEntity',  x = 655,  y = 589,  order = 0,  isVisible = false,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/fly_clock_1.png',  width = 250,  height = 250,  },
		{ name = 'bbt_01_vortex',  entityType = 'SpriteEntity',  x = 653,  y = 96,  order = 100,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 400,  height = 180,  },
		{ name = 'molinari_1',  entityType = 'VideoEntity',  x = 575,  y = 464,  order = 400,  editingLocked = false,  treeItemIsExpanded = false,  path = 'Data/Video/Scenes/01_Boat_crash_site/Molinari_1.webm',  hasAlpha = true,  isLooped = true,  fps = 24,  },
		{ name = 'box_intrctv_1',  entityType = 'SpriteEntity',  x = 728,  y = 390,  order = 55,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/box_intrctv_1.png',  width = 185,  height = 56,  },
		{ name = 'box_intrctv_2',  entityType = 'SpriteEntity',  x = 771,  y = 382,  order = 55,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Scenes/01_Boat_crash_site/Layers/box_intrctv_2.png',  width = 105,  height = 65,  },
		{ name = '01_Boat_crash_site_Anim_Bg',  entityType = 'CompositionContainer',  x = -171,  y = 0,  order = 60,  editingLocked = false,  treeItemIsExpanded = true,  path = 'Data/Scripts/Scenes/01_Boat_crash_site/Anim/01_Boat_crash_site_Anim_Bg.lua',  },
		{ name = 'compositionBG3',  entityType = 'CompositionSequence',  parentName = '01_Boat_crash_site_Anim_Bg',  x = 0,  y = 0,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  isCyclic = true,  speed = 1,  },
		{ name = 'compositionMolniya',  entityType = 'CompositionSequence',  parentName = '01_Boat_crash_site_Anim_Bg',  x = 0,  y = 0,  order = 0,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  speed = 1,  },
		{ name = 'compositionMolniya2',  entityType = 'CompositionSequence',  parentName = '01_Boat_crash_site_Anim_Bg',  x = 0,  y = 0,  order = 0,  isActive = false,  editingLocked = false,  treeItemIsExpanded = false,  speed = 1,  },
	}
	return objects
end
