local PATH_COMICS_34_ON_SHOWN           = 'data/Scenes/Comics/HelpersComicsReplic.lua'
local PATH_COMICS_34_COIN               = 'data/Scenes/Comics/HelpersComicsReplic.lua'
local PATH_COMICS_34_SHIELD             = 'data/Scenes/Comics/HelpersComicsReplic.lua'
local PATH_COMICS_34_ON_WIN             = 'data/Scenes/Comics/HelpersComicsReplic.lua'

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad(screen:GetName())

    local pf = play_field
    local level = pf:GetLevelScreen()
    ---------------------------------------------------------------------------------------------
    level:AddTaskSafe(CreateTask('COIN', '', 'coin'))
    AddRandomTasks(15,
         CreateTask('BOOMERANG', '', 'boomerang'),
         CreateTask('BUTTERFLY', '', 'butterfly'),
         CreateTask('CRADLE', '', 'cradle'),
         CreateTask('FIFE', '', 'fife'),
         CreateTask('LIZARD', 'LIZARDS', 'lizard', 'lizard_2'),
         CreateTask('MARACAS', '', 'maracas'),
         CreateTask('TOTEM', '', 'totem'),
         
         CreateTask('BIRD', '', 'bird'),
         CreateTask('BULL', '', 'bull'),
         CreateTask('CRAWFISH', '', 'crawfish'),
         CreateTask('DRAGON', '', 'dragon'),
         CreateTask('DRAGONFLY', 'DRAGONFLIES', 'dragonfly', 'dragonfly_2'),
         CreateTask('FEATHER', '', 'feather'),
         CreateTask('CHAMELEON', '', 'chameleon'),
         CreateTask('KNOT', '', 'knot'),
         CreateTask('NEST', '', 'nest'),
         CreateTask('PEAPOD', '', 'peas'),
         CreateTask('PEPPER', '', 'pepper'),
         CreateTask('RING', '', 'ring'),
         CreateTask('SKULL', '', 'skull'),
         CreateTask('SWORD', '', 'sword')
    )
    pf:IgnoreOnTestPoint('coin')
    ---------------------------------------------------------------------------------------------
    local zone_shield = CreateZoomZone('close_zone_shield',
                                       'pixel_open_shield',
                                       'Zoom_Shield',
                                       'coin',
                                       'shield_part'
                                      )
    ---------------------------------------------------------------------------------------------
    pf:GetObject('shield_full'):GetAnimation():SetColor('0xFFFFFFFF')
    pf:GetObject('shield_break'):GetAnimation():SetColor('0xFFFFFFFF')
    pf:GetObject('shield_full'):SetOpacity(1)
    pf:GetObject('shield_break'):SetOpacity(0)
    apply_action_axe = function(save)
                            if save then
                                pf:GetObject('shield_part'):SetMaxOpacity(0)
                                pf:GetObject('shield_full'):SetOpacity(0)
                                pf:GetObject('shield_break'):SetOpacity(1)
                            else
                                zone_shield.ChangeObjOpacity('shield_part', 1, 0, 0.3)
                                pf:GetObject('shield_full'):ChangeOpacity(1, 0, 0.3)
                                pf:GetObject('shield_break'):ChangeOpacity(0, 1, 0.3)
                                
                                MakeSoundEntity('34_cut_shield'):Play(false)
                            end
                            
                            if pf:IsIgnoredOnTestPoint( pf:GetObject('coin') ) then
                                pf:DoNotIgnoreOnTestPoint('coin')
                            end
                       end
	local photo_axe   = CreatePhotoZone('axe', 'AXE', 'photo_axe', nil, 'shield_part', apply_action_axe)
	---------------------------------------------------------------------------------------------
    local photo_water   = CreatePhotoZoneEx(nil, 'bulb_water', 'BULB_WATER', 'photo_bulb_water', nil, nil, nil)
    photo_water.zone.SetPhotoMade()
    ---------------------------------------------------------------------------------------------
	game_state.chain_on_shown = RegisterComicsEx(function()
                                                    local comics = LoadComics(PATH_COMICS_34_ON_SHOWN, 'COMICS_34_ON_SHOWN')
                                                    if comics then
                                                        CreateOneSMS('COMICS_34_ON_SHOWN_1', 1)
                                                        CreateOneReplicHeroes('COMICS_34_ON_SHOWN_2', 2)
                                                     end
                                                 end )
    game_state.chain_coin = RegisterComicsEx(function()
	                                                LoadComicsWithOneReplicHeroes(PATH_COMICS_34_COIN, 'COMICS_34_COIN')
	                                             end )
    game_state.chain_coin.OnHidden = function()
        OnWin()
    end
    game_state.chain_shield = RegisterComicsEx(function()
	                                                LoadComicsWithOneReplicHeroes(PATH_COMICS_34_SHIELD, 'COMICS_34_SHIELD')
	                                             end )
    SetHintComicsPhotoZoneEx(photo_axe, game_state.chain_shield)
    game_state.chain_on_win = RegisterComicsEx(function()
	                                                LoadComicsWithOneReplicHeroes(PATH_COMICS_34_ON_WIN, 'COMICS_34_ON_WIN')
	                                             end )
    game_state.chain_on_win.OnHidden = function()
        OnWinLevel()
    end
    ---------------------------------------------------------------------------------------------
    pf:IgnoreOnTestPoint('shadow_tree')
    ---------------------------------------------------------------------------------------------
end

function OnSceneFree()
    FreeData()
end

function OnScreenShown(fade_out)
    if fade_out then
        game_state.chain_on_shown.Play()
    end
end

function OnHiddenComics()
end

function OnMinigameCompleted(mini_game)
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)
end

function OnLose()
end

function OnExit()
end

function OnButtonMouseEnter(title)
end

function OnButtonMouseLeave(title)
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    obj_name = object:GetName()
    local pf = play_field
    local is_wrong_click = true

    is_wrong_click = DefaultOnObjectMouseDown(object)
    
    return is_wrong_click
end

function OnObjectMouseUp(object)
end

function OnObjectRightMouseDown(object)
end

function OnObjectRightMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
    
    if object:GetName() == 'coin' then
        game_state.chain_coin.Play()
    end
end

function OnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnPhotographing()
	DefaultOnPhotographing()
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function OnLostFocus()
end

function OnGainFocus()
end

function OnWin()
    if  play_field:GetLevelScreen():IsCompleteLevel() and
        game_state.chain_coin.played
    then
        game_state.chain_on_win.Play()
    end
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/layers/bg.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bg',anim,512,384,70,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/boomerang.png',0,0,49,41,1,0)
	anim:SetHotSpot(24,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('boomerang',anim,552,36,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/butterfly.png',0,0,49,40,1,0)
	anim:SetHotSpot(24,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('butterfly',anim,672,735,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/cradle.png',0,0,183,99,1,0)
	anim:SetHotSpot(91,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('cradle',anim,586,507,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/fife.png',0,0,75,49,1,0)
	anim:SetHotSpot(37,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fife',anim,617,667,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/lizard.png',0,0,79,46,1,0)
	anim:SetHotSpot(39,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('lizard',anim,833,732,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/maracas.png',0,0,99,53,1,0)
	anim:SetHotSpot(49,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('maracas',anim,260,625,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/totem.png',0,0,160,150,1,0)
	anim:SetHotSpot(80,75)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('totem',anim,690,466,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/axe.png',0,0,145,59,1,0)
	anim:SetHotSpot(72,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('axe',anim,488,638,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/photo/photo_axe.jpg',0,0,177,298,1,0)
	anim:SetHotSpot(88,149)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('photo_axe',anim,83,822,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_open_shield',anim,823,359,200,0,12,28)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/zoom_shield/Zoom_Shield.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Zoom_Shield',anim,512,384,700,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/zoom_shield/coin.png',0,0,36,30,1,0)
	anim:SetHotSpot(18,15)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('coin',anim,545,393,720,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/zoom_shield/shield_part.png',0,0,258,480,1,0)
	anim:SetHotSpot(129,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('shield_part',anim,570,383,740,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/layers/shield_full.png',0,0,100,226,1,0)
	anim:SetHotSpot(50,113)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('shield_full',anim,833,353,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/layers/shield_break.png',0,0,100,226,1,0)
	anim:SetHotSpot(50,113)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('shield_break',anim,833,353,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/photo/photo_bulb_water.jpg',0,0,177,298,1,0)
	anim:SetHotSpot(88,149)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('photo_bulb_water',anim,83,627,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/bulb_water.png',0,0,89,108,1,0)
	anim:SetHotSpot(44,54)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bulb_water',anim,79,380,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/bird.png',0,0,48,34,1,0)
	anim:SetHotSpot(24,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bird',anim,885,177,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/bull.png',0,0,86,87,1,0)
	anim:SetHotSpot(43,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bull',anim,371,178,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/crawfish.png',0,0,51,90,1,0)
	anim:SetHotSpot(25,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('crawfish',anim,748,159,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/dragon.png',0,0,72,69,1,0)
	anim:SetHotSpot(36,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dragon',anim,989,538,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/dragonfly.png',0,0,56,66,1,0)
	anim:SetHotSpot(28,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dragonfly',anim,972,199,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/dragonfly_2.png',0,0,56,58,1,0)
	anim:SetHotSpot(28,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dragonfly_2',anim,487,197,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/feather.png',0,0,35,38,1,0)
	anim:SetHotSpot(17,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('feather',anim,238,274,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/chameleon.png',0,0,58,69,1,0)
	anim:SetHotSpot(29,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('chameleon',anim,618,167,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/knot.png',0,0,31,83,1,0)
	anim:SetHotSpot(15,41)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('knot',anim,616,75,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/lizard_2.png',0,0,33,100,1,0)
	anim:SetHotSpot(16,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('lizard_2',anim,679,266,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/nest.png',0,0,86,65,1,0)
	anim:SetHotSpot(43,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('nest',anim,263,86,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/peas.png',0,0,66,80,1,0)
	anim:SetHotSpot(33,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('peas',anim,990,679,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/pepper.png',0,0,41,51,1,0)
	anim:SetHotSpot(20,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('pepper',anim,377,62,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/ring.png',0,0,50,52,1,0)
	anim:SetHotSpot(25,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('ring',anim,752,573,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/skull.png',0,0,32,39,1,0)
	anim:SetHotSpot(16,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('skull',anim,405,266,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/items/sword.png',0,0,29,148,1,0)
	anim:SetHotSpot(14,74)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('sword',anim,872,307,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/34_temple_1_/anim/shadow_tree.png',0,0,325,173,23,12)
	anim:SetHotSpot(162,86)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('shadow_tree',anim,862,86,100,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
