dofile('data/Scenes/24_Doll.lua')

local zone_window
local rune_is_in_correct_place = false

function add_fibrillation_effector_door_light(obj, delay)
	local duration = 7.0

	eff= CreateAnimationEffector()
	eff:AttachTo(obj)
	eff:SetMode(_ANIM_LOOP)

    local dopacity = -0.

	eff:SetKey(_TRACK_O, 0.0 + delay, 1.0 + dopacity)
	eff:SetKey(_TRACK_O, duration * 1.0/4.0 + delay, 0.75 + dopacity)
	eff:SetKey(_TRACK_O, duration * 2.0/4.0 + delay, 1.0 + dopacity)
	eff:SetKey(_TRACK_O, duration * 3.0/4.0 + delay, 0.59 + dopacity)
	eff:SetKey(_TRACK_O, duration * 4.0/4.0 + delay, 1.0 + dopacity)
	eff:Play()
end

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/24_Dolls_Main.lua', 'quest')

	LinkScene('area_back', 'CursorDoorLeft', 'data/Scenes/22_Backstage_Main.lua', false)
	LinkScene('area_ho', 'CursorGlass', 'data/Scenes/24_Dolls_HO.lua', true)
	LinkScene('area_zoom_window', 'CursorGlass', 'data/Scenes/24_Mosaic.lua', false)

	game_state.object_highlight_delay = game_state.object_highlight_delay * 1.5
	game_state.object_highlight_period = game_state.object_highlight_period * 3.
	if not HasGameState('ToolFound', '24_pimpa') then
		RegisterQuestObjects('area_zoom_doll')
	end
	if not HasGameState('ToolFound', '24_runa') then
		RegisterQuestObjects('area_zoom_window', 'area_zoom_window_2')
	end

	screen:GetObject('Layer_Puzzle_Over'):SetVisible(false);
	screen:GetObject('Layer_WindowPuzzle'):SetVisible(false);
	screen:GetObject('area_rune'):SetMaxOpacity(0.001);

	add_fibrillation_effector_door_light(play_field:GetObject('light_from_door'), 0)

	if HasGameState('MiniGameCompleted', '24_Mosaic') == false then
		screen:GetObject("area_zoom_window"):SetVisible(true);
		screen:GetObject("area_zoom_window_2"):SetVisible(false);
		open_window = createCompositionBG_Dolls();
		open_window:AttachTo(screen);
		open_window:SetZ(120);
		open_window:SetDestroysOnEnd(false);
	else
		screen:GetObject("area_zoom_window"):SetVisible(false);
		screen:GetObject("area_zoom_window_2"):SetVisible(true);
		play_field:GetObject('Layer_WindowPuzzle'):SetVisible(false);
	end

	zone_window = CreateZoomZone('area_zoom_window_2',
								 'CloseZoneWindow',
								 'BG_Window', true,
								 --'Layer_Top', true,
								 'area_house', true,
								 'Layer_Rune_Over', true,
								 'Rune', true,
								 'area_rune', true,
                                 'shtorka', true)
	play_field:GetObject('area_house'):SetMaxOpacity(0.001)
	RegisterMonologObject('area_house', 'C_24_HOUSE', true)

	zone_window.on_open = function()		
		if(HasGameState('ToolFound', '24_runa')) then
			play_field:GetObject('Rune'):SetVisible(false);
			play_field:GetObject('area_rune'):SetVisible(false);
		else
			play_field:GetObject('Rune'):SetVisible(true);
			play_field:GetObject('area_rune'):SetVisible(true);
		end
		
		play_field:GetObject('Layer_WindowPuzzle'):SetVisible(false);
		
		if not HasGameState('SpiderManVanished', '24') then
			TimerDoString("MoveRune()", 7.0, play_field:GetTimer())
			zone_window.SetObjectVisible('shtorka', false);
            PlaySpiderManFleeingAnimation();
            MakeSoundEntity('24_Spider'):Play(false);
            AddGameState('SpiderManVanished', '24');
            if not HasGameState('ToolFound', '24_runa') then
				PressKey = function()
					play_field:GetObject('Rune'):ChangeOpacity(1.0, 0.0, 0.4)
					TimerDoString("FindTool('24_runa')", 0.4, play_field:GetTimer())
					zone_window.SetVisible(false);
					game_state.ignore_on_highlight['area_zoom_window_2'] = true
					AddGameState('IgnoreOnHighlight', 'area_zoom_window_2')
					play_field:GetObject('area_rune'):SetVisible(false);
				end
			
			    TimerDoString("play_field:GetObject('area_rune'):SetVisible(true);", 10.0, play_field:GetTimer())
				TimerDoString('RegisterActiveObject("area_rune", PressKey, nil, true, "CursorActive");', 10.0, play_field:GetTimer())
			end
        else
			if(HasGameState('ToolFound', '24_runa') == false) then
				PressKey = function()
					play_field:GetObject('Rune'):ChangeOpacity(1.0, 0.0, 0.4)
					TimerDoString("FindTool('24_runa')", 0.4, play_field:GetTimer())
					zone_window.SetVisible(false);
					game_state.ignore_on_highlight['area_zoom_window_2'] = true
					AddGameState('IgnoreOnHighlight', 'area_zoom_window_2')
					play_field:GetObject('area_rune'):SetVisible(false);
				end
				
				RegisterActiveObject('area_rune', PressKey, nil, true, 'CursorActive');
			end
            zone_window.SetObjectVisible('shtorka', true);
            play_field:GetObject("Rune"):SetXY(play_field:GetObject("Rune"):GetX(), 260);
			rune_is_in_correct_place = true
        end

		-- PS-1580
		TimerDoString("play_field:GetObject('Rune'):DestroyChildren() play_field:GetObject('Rune'):ChangeOpacity(0., 1., 0.5)", 0, play_field:GetTimer())
	end

	zone_window.on_close = function()
		UnregisterActiveObject('area_rune');

		-- PS-1580
		play_field:GetObject('Rune'):SetOpacity(0.3)

	    if (play_field.spiderCompos)
	    then
	        play_field.spiderCompos:Destroy();
	        play_field.spiderCompos = nil;
	    end
	
	end
	
	if(minigame_complited == true) then
		minigame_complited = false
		open_window = createCompositionBG_Dolls();
		open_window:AttachTo(screen);
		open_window:SetZ(120)
		open_window:SetDestroysOnEnd(false);
		open_window:Play();
		MakeSoundEntity('24_Window_bars_open'):Play(false);
		--play_field:GetObject('Layer_WindowPuzzle'):SetVisible(true);
		--play_field:GetObject('Layer_WindowPuzzle'):Move(0.0, -120, 2.0);
	end
	
	RegisterMonologObject('area_whimsical_doll', 'C_24_WHIMSICAL_DOLL', true)
	
	LoadSound('24_Window_bars_open', 'data/Sound/24_Dolls/Window_bars_open.ogg');
	LoadSound('24_Spider', 'data/Sound/24_Dolls/24_Spider.ogg');

	OnMiniGameInit(screen);
end

function MoveRune()
	if not rune_is_in_correct_place then
		play_field:GetObject("Rune"):Move(0.0, 210.0, 2.0)
	end
end

function PlaySpiderManFleeingAnimation()

    createCompositionSpiderMan = function()
    
        local compositionSpiderMan = CreateCompositionSequence();
        local compositionDuration = 9;
        compositionSpiderMan:SetDuration(compositionDuration);
    
    
        -- Layer Light_eye_1
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/light.png");
        element:SetName("Light_eye_1");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(24, 24);
        element:SetParentElement(compositionSpiderMan);
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
    
        effector = element:GetEffector();
        effector:SetLifeTime(0, 0.75);
    
        effector:SetKey(_TRACK_X, 0, 173);
        effector:SetKey(_TRACK_Y, 0, 91);
        effector:SetKey(_TRACK_X, 0.16666666666667, 237.857597656666);
        effector:SetKey(_TRACK_Y, 0.16666666666667, 103.143180555851);
        effector:SetKey(_TRACK_X, 0.58333333333333, 278);
        effector:SetKey(_TRACK_Y, 0.58333333333333, 152);
        effector:SetKey(_TRACK_O, 0, 0);
        effector:SetKey(_TRACK_O, 0.08333333333333, 0.17);
        effector:SetKey(_TRACK_O, 0.33333333333333, 0);
        effector:SetKey(_TRACK_O, 0.41666666666667, 0.06);
        effector:SetKey(_TRACK_O, 0.58333333333333, 0.3);
        effector:SetKey(_TRACK_O, 0.66666666666667, 0.21);
        effector:SetKey(_TRACK_O, 0.75, 0.05);
    
        effector:Play();
    
    
        -- Layer Curtain_static_1
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/shtorka.png");
        element:SetName("Curtain_static_1");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(213.5, 167);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(214, 167);
        
            anim = element:GetTexture();
			anim:SetTextureRect(0, 0, 427, 334);
			
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(0, 0.83333333333333);
    
    
        effector:Play();
    
    
        -- Layer Curtain_static_2
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/shtorka.png");
        element:SetName("Curtain_static_2");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(213.5, 167);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(214, 167);
        
            anim = element:GetTexture();
			anim:SetTextureRect(0, 0, 427, 334);
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(1.75, 9.1);
    
    
        effector:Play();
    
    
        -- Layer Curtain_waves
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/shtorka.png");
        element:SetName("Curtain_waves");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(213.5, 167);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(214, 167);
        
            anim = element:GetTexture();
			anim:SetSpeed(15);
			anim:SetFrames(11);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 427, 334);
			anim:SetMode(HGEANIM_FWD);
			anim:Play();
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(0.83333333333333, 1.75);
    
    
        effector:Play();
    
    
        -- Layer Light_eye_2
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/light.png");
        element:SetName("Light_eye_2");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(24, 24);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(632, 600);
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
    
        effector = element:GetEffector();
        effector:SetLifeTime(4.58333333333333, 5.41666666666667);
    
        effector:SetKey(_TRACK_O, 4.91666666666667, 0);
        effector:SetKey(_TRACK_O, 5, 0.06);
        effector:SetKey(_TRACK_O, 5.16666666666667, 1);
        effector:SetKey(_TRACK_O, 5.25, 0.95);
        effector:SetKey(_TRACK_O, 5.33333333333333, 0.05);
    
        effector:Play();
    
    
        -- Layer Key_rotating
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/key.png");
        element:SetName("Key_rotating");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(30.5, 29.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(651, 697);
        
            anim = element:GetTexture();
			anim:SetSpeed(15);
			anim:SetFrames(10);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 61, 59);
			anim:SetMode(HGEANIM_FWD);
			anim:Play();
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(4.58333333333333, 5.41666666666667);
    
    
        effector:Play();
    
    
        -- Layer Spider_sitting_1
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/static.png");
        element:SetName("Spider_sitting_1");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(120.5, 114);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(656, 636);
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(4.58333333333333, 5.41666666666667);
    
    
        effector:Play();
    
    
        -- Layer Spider_running_4
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/Spider_4.png");
        element:SetName("Spider_running_4");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(82, 104.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(665, 640);
        
            anim = element:GetTexture();
			anim:SetSpeed(15);
			anim:SetFrames(6);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 164, 209);
			anim:SetMode(HGEANIM_FWD);
			anim:Play();
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(5.41666666666667, 5.91666666666667);
    
    
        effector:Play();
    
    
        -- Layer Spider_running_3
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/Spider_3.png");
        element:SetName("Spider_running_3");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(120.5, 114);
        element:SetParentElement(compositionSpiderMan);
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
        
            anim = element:GetTexture();
			anim:SetSpeed(25);
			anim:SetFrames(10);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 241, 228);
			anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
			anim:Play();
    
        effector = element:GetEffector();
        effector:SetLifeTime(2.91666666666667, 4.58333333333333);
    
        effector:SetKey(_TRACK_X, 2.91666666666667, 307);
        effector:SetKey(_TRACK_Y, 2.91666666666667, 620);
        effector:SetKey(_TRACK_X, 4.5, 641);
        effector:SetKey(_TRACK_Y, 4.5, 634);
    
        effector:Play();
    
    
        -- Layer Spider_sitting_2
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/Spider_2.png");
        element:SetName("Spider_sitting_2");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(135.5, 133.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(311, 609);
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
        
            anim = element:GetTexture();
			anim:SetSpeed(24);
			anim:SetFrames(19);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 271, 267);
			anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
			anim:Play();
    
        effector = element:GetEffector();
        effector:SetLifeTime(2.16666666666667, 2.95833333333333);
    
    
        effector:Play();
    
    
        -- Layer Spider_running_1
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/Spider_1.png");
        element:SetName("Spider_running_1");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(108.5, 100.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
        
            anim = element:GetTexture();
			anim:SetSpeed(24);
			anim:SetFrames(10);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 217, 201);
			anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
			anim:Play();
    
        effector = element:GetEffector();
        effector:SetLifeTime(0.83333333333333, 2.16666666666667);
    
        effector:SetKey(_TRACK_X, 0.83333333333333, 282);
        effector:SetKey(_TRACK_Y, 0.83333333333333, 145);
        effector:SetKey(_TRACK_X, 2.08333333333333, 286);
        effector:SetKey(_TRACK_Y, 2.08333333333333, 578);
    
        effector:Play();
    
    
        -- Layer Layer_wood
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/layer.png");
        element:SetName("Layer_wood");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(70.5, 45.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(748.5, 724.5);
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(0, 15);
    
    
        effector:Play();
    
    
        -- Layer Spider_running_5
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/Spider_5.png");
        element:SetName("Spider_running_5");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(48.5, 45.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetAngle(0);
        element:SetOpacity(1);
        
            anim = element:GetTexture();
			anim:SetSpeed(40);
			anim:SetFrames(10);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 97, 91);
			anim:SetMode(HGEANIM_FWD + HGEANIM_LOOP);
			anim:Play();
    
        effector = element:GetEffector();
        effector:SetLifeTime(7.33333333333333, 8.75);
    
        effector:SetKey(_TRACK_X, 7.33333333333333, 743);
        effector:SetKey(_TRACK_Y, 7.33333333333333, 722);
        effector:SetKey(_TRACK_X, 8.08333333333333, 703.000206812745);
        effector:SetKey(_TRACK_Y, 8.08333333333333, 550.750396391095);
        effector:SetKey(_TRACK_X, 8.66666666666667, 592);
        effector:SetKey(_TRACK_Y, 8.66666666666667, 450);
        effector:SetKey(_TRACK_SX, 7.33333333333333, 1);
        effector:SetKey(_TRACK_SY, 7.33333333333333, 1);
        effector:SetKey(_TRACK_SX, 8.66666666666667, 0.36);
        effector:SetKey(_TRACK_SY, 8.66666666666667, 0.36);
    
        effector:Play();
    
    
        -- Layer Door_opening
        local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/door.png");
        element:SetName("Door_opening");
        compositionSpiderMan:AddElement(element);
        element:SetHotSpot(34, 46.5);
        element:SetParentElement(compositionSpiderMan);
        element:SetXY(585, 430);
        
            anim = element:GetTexture();
			anim:SetSpeed(15);
			anim:SetFrames(3);
			anim:SetFrame(0);
			anim:SetTextureRect(0, 0, 68, 93);
			anim:SetMode(HGEANIM_FWD);
			anim:Play();
    
        element:SetScaleX(1);
        element:SetScaleY(1);
        element:SetAngle(0);
        element:SetOpacity(1);
    
        effector = element:GetEffector();
        effector:SetLifeTime(8.41666666666667, 8.71666666666667);
    
    
        effector:Play();
    
        compositionSpiderMan:Play();
    
        return compositionSpiderMan;
    end
    
    local compos = createCompositionSpiderMan();
    compos:AttachTo(play_field);
    compos:SetZ(159);
    compos:SetDestroysOnEnd(false);
    play_field.spiderCompos = compos;
    
end

function OnSceneFree(screen)
    DefaultOnSceneFree()
    FreeData(screen)
end

function OnUpdate(dt)
	MG_Update(dt)
    DefaultOnUpdate(dt)
end

function OnAllItemsFound()
    DefaultOnAllItemsFound()
end

function OnLose()
    DefaultOnLose()
end

function OnExit()
    DefaultOnExit()
end

function OnClose()
    DefaultOnClose()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

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

	
	MG_OnObjectMouseDown(object);
    DefaultOnObjectMouseDownProcessed(is_wrong_click);
end

function OnObjectMouseUp(object)
	MG_OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
end

function OnToolFound(tool)
    DefaultOnToolFound(tool)
end

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

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
    DefaultOnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
    DefaultOnSetTool(tool)
end

function LevelLoaded(level)
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
end

createCompositionBG_Dolls = function()

	local compositionBG_Dolls = CreateCompositionSequence();
	local compositionDuration = 2.2;
	compositionBG_Dolls:SetDuration(compositionDuration);


	-- Layer Layer_1
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_Puzzle_Over.png");
	element:SetName("Layer_1");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(88, 142);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(891, 346);

	element:SetScaleX(1);
	element:SetScaleY(1);
	element:SetAngle(0);
	element:SetOpacity(1);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 30.25);


	effector:Play();


	-- Layer Layer_2
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_2");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(947.5, 341.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.2, 1.08);

	effector:SetKey(_TRACK_SX, 0.2, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.2, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.04, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.04, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.2, 0);
	effector:SetKey(_TRACK_O, 0.4, 0.33);
	effector:SetKey(_TRACK_O, 1.04, 0);

	effector:Play();


	-- Layer Layer_3
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_3");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(826, 331.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.52, 1.4);

	effector:SetKey(_TRACK_SX, 0.52, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.52, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.36, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.36, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.52, 0);
	effector:SetKey(_TRACK_O, 0.72, 0.33);
	effector:SetKey(_TRACK_O, 1.36, 0);

	effector:Play();


	-- Layer Layer_4
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_4");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(871, 334.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.2, 1.08);

	effector:SetKey(_TRACK_SX, 0.2, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.2, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.04, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.04, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.2, 0);
	effector:SetKey(_TRACK_O, 0.4, 0.33);
	effector:SetKey(_TRACK_O, 1.04, 0);

	effector:Play();


	-- Layer Layer_5
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_5");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(937.5, 339.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 0.88);

	effector:SetKey(_TRACK_SX, 0, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 0.84, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 0.84, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0, 0);
	effector:SetKey(_TRACK_O, 0.2, 0.33);
	effector:SetKey(_TRACK_O, 0.84, 0);

	effector:Play();


	-- Layer Layer_6
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_6");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(923, 334.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.2, 1.08);

	effector:SetKey(_TRACK_SX, 0.2, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.2, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.04, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.04, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.2, 0);
	effector:SetKey(_TRACK_O, 0.4, 0.33);
	effector:SetKey(_TRACK_O, 1.04, 0);

	effector:Play();


	-- Layer Layer_7
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_7");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(876.5, 330.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.48, 1.36);

	effector:SetKey(_TRACK_SX, 0.48, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.48, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.32, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.32, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.48, 0);
	effector:SetKey(_TRACK_O, 0.68, 0.33);
	effector:SetKey(_TRACK_O, 1.32, 0);

	effector:Play();


	-- Layer Layer_8
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_8");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(844.5, 334.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 0.88);

	effector:SetKey(_TRACK_SX, 0, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 0.84, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 0.84, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0, 0);
	effector:SetKey(_TRACK_O, 0.2, 0.33);
	effector:SetKey(_TRACK_O, 0.84, 0);

	effector:Play();


	-- Layer Layer_9
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_WindowPuzzle.PNG");
	element:SetName("Layer_9");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(66, 107);
	element:SetParentElement(compositionBG_Dolls);
	element:SetOpacity(1);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 30.25);

	effector:SetKey(_TRACK_X, 0, 887);
	effector:SetKey(_TRACK_Y, 0, 463);
	effector:SetKey(_TRACK_X, 0.1, 887.014497743551);
	effector:SetKey(_TRACK_Y, 0.1, 462.513289640664);
	effector:SetKey(_TRACK_X, 0.2, 887.055952651696);
	effector:SetKey(_TRACK_Y, 0.2, 461.121589425428);
	effector:SetKey(_TRACK_X, 0.3, 887.121305671726);
	effector:SetKey(_TRACK_Y, 0.3, 458.927595086965);
	effector:SetKey(_TRACK_X, 0.4, 887.207942841702);
	effector:SetKey(_TRACK_Y, 0.4, 456.019062715548);
	effector:SetKey(_TRACK_X, 0.5, 887.313738239581);
	effector:SetKey(_TRACK_Y, 0.5, 452.467359908109);
	effector:SetKey(_TRACK_X, 0.6, 887.43696345906);
	effector:SetKey(_TRACK_Y, 0.6, 448.330512346128);
	effector:SetKey(_TRACK_X, 0.7, 887.575870708997);
	effector:SetKey(_TRACK_Y, 0.7, 443.667198091219);
	effector:SetKey(_TRACK_X, 0.8, 887.729590214063);
	effector:SetKey(_TRACK_Y, 0.8, 438.506613735621);
	effector:SetKey(_TRACK_X, 0.9, 887.897121058878);
	effector:SetKey(_TRACK_Y, 0.9, 432.882365073593);
	effector:SetKey(_TRACK_X, 1, 888.077643582763);
	effector:SetKey(_TRACK_Y, 1, 426.821964962751);
	effector:SetKey(_TRACK_X, 1.1, 888.270367596014);
	effector:SetKey(_TRACK_Y, 1.1, 420.351945651222);
	effector:SetKey(_TRACK_X, 1.2, 888.474712833166);
	effector:SetKey(_TRACK_Y, 1.2, 413.491784083089);
	effector:SetKey(_TRACK_X, 1.3, 888.690188063916);
	effector:SetKey(_TRACK_Y, 1.3, 406.257972687691);
	effector:SetKey(_TRACK_X, 1.4, 888.916408122701);
	effector:SetKey(_TRACK_Y, 1.4, 398.663442121278);
	effector:SetKey(_TRACK_X, 1.5, 889.153094418164);
	effector:SetKey(_TRACK_Y, 1.5, 390.717544861465);
	effector:SetKey(_TRACK_X, 1.6, 889.400108385543);
	effector:SetKey(_TRACK_Y, 1.6, 382.424932847442);
	effector:SetKey(_TRACK_X, 1.7, 889.657482857177);
	effector:SetKey(_TRACK_Y, 1.7, 373.784504080496);
	effector:SetKey(_TRACK_X, 1.8, 889.925291441728);
	effector:SetKey(_TRACK_Y, 1.8, 364.793787811739);
	effector:SetKey(_TRACK_X, 1.9, 890.204998832413);
	effector:SetKey(_TRACK_Y, 1.9, 355.403609820417);
	effector:SetKey(_TRACK_X, 2, 890.5);
	effector:SetKey(_TRACK_Y, 2, 345.5);
	effector:SetKey(_TRACK_SX, 0, 1);
	effector:SetKey(_TRACK_SY, 0, 1);
	effector:SetKey(_TRACK_SX, 0.92, 1);
	effector:SetKey(_TRACK_SY, 0.92, 1.00378673698714);
	effector:SetKey(_TRACK_SX, 1, 1);
	effector:SetKey(_TRACK_SY, 1, 0.995160376043);
	effector:SetKey(_TRACK_SX, 1.12, 1);
	effector:SetKey(_TRACK_SY, 1.12, 1.0074411619804);
	effector:SetKey(_TRACK_SX, 1.2, 1);
	effector:SetKey(_TRACK_SY, 1.2, 1.00378673698714);
	effector:SetKey(_TRACK_SX, 1.3, 1);
	effector:SetKey(_TRACK_SY, 1.3, 0.9951603747673);
	effector:SetKey(_TRACK_SX, 1.4, 1);
	effector:SetKey(_TRACK_SY, 1.4, 1.00000000039936);
	effector:SetKey(_TRACK_SX, 1.5, 1);
	effector:SetKey(_TRACK_SY, 1.5, 0.991066011536);
	effector:SetKey(_TRACK_SX, 1.6, 1);
	effector:SetKey(_TRACK_SY, 1.6, 1.01572985015412);
	effector:SetKey(_TRACK_SX, 1.7, 1);
	effector:SetKey(_TRACK_SY, 1.7, 0.99742179631947);
	effector:SetKey(_TRACK_SX, 1.8, 1);
	effector:SetKey(_TRACK_SY, 1.8, 0.98746726889859);
	effector:SetKey(_TRACK_SX, 1.9, 1);
	effector:SetKey(_TRACK_SY, 1.9, 1.00378673665578);
	effector:SetKey(_TRACK_SX, 2, 1);
	effector:SetKey(_TRACK_SY, 2, 1);
	effector:SetKey(_TRACK_A, 0.76, 0);
	effector:SetKey(_TRACK_A, 2, -0.05989585635442);

	effector:Play();


	-- Layer Layer_10
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_10");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(929.5, 426.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 0.88);

	effector:SetKey(_TRACK_SX, 0, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 0.84, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 0.84, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0, 0);
	effector:SetKey(_TRACK_O, 0.2, 0.33);
	effector:SetKey(_TRACK_O, 0.84, 0);

	effector:Play();


	-- Layer Layer_11
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_11");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(887, 419);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0.2, 1.08);

	effector:SetKey(_TRACK_SX, 0.2, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0.2, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 1.04, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 1.04, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0.2, 0);
	effector:SetKey(_TRACK_O, 0.4, 0.33);
	effector:SetKey(_TRACK_O, 1.04, 0);

	effector:Play();


	-- Layer Layer_12
	local element = CreateCompositionElement("data/Texture/Scenes/24_Dolls/Zone_Main/Layers/dust2.png");
	element:SetName("Layer_12");
	compositionBG_Dolls:AddElement(element);
	element:SetHotSpot(31.5, -1.5);
	element:SetParentElement(compositionBG_Dolls);
	element:SetXY(855.5, 417.5);

	element:SetAngle(0);

	effector = element:GetEffector();
	effector:SetLifeTime(0, 0.88);

	effector:SetKey(_TRACK_SX, 0, 0.79365079365079);
	effector:SetKey(_TRACK_SY, 0, 0.69767441860465);
	effector:SetKey(_TRACK_SX, 0.84, 1.68253968253968);
	effector:SetKey(_TRACK_SY, 0.84, 1.64341085271318);
	effector:SetKey(_TRACK_O, 0, 0);
	effector:SetKey(_TRACK_O, 0.2, 0.33);
	effector:SetKey(_TRACK_O, 0.84, 0);

	effector:Play();

	return compositionBG_Dolls;
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/24_Dolls/Zone_Main/Layers/BG_Dolls.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_Dolls',anim,512,384,45,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_back',anim,252,416,100,0,20,30)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_window',anim,884,429,108,0,20,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_window_2',anim,884,429,107,0,20,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_doll',anim,668,448,100,0,15,15)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_ho',anim,524,612,100,0,35,25)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_WindowPuzzle.PNG',0,0,132,138,1,0)
	anim:SetHotSpot(66,69)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_WindowPuzzle',anim,888,422,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_Light.PNG',0,0,323,323,1,0)
	anim:SetHotSpot(161,161)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Light',anim,884,523,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/BG_Window.JPG',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Window',anim,512,384,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Layer_Top.png',0,0,1024,436,1,0)
	anim:SetHotSpot(0,0)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Layer_Top',anim,0,0,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_house',anim,672,390,160,0,40,20)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_Puzzle_Over.png',0,0,176,284,1,0)
	anim:SetHotSpot(88,122)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Puzzle_Over',anim,891,326,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_whimsical_doll',anim,110,513,99,0,26,28)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Animations/shtorka.png',0,0,427,334,1,0)
	anim:SetHotSpot(213,167)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('shtorka',anim,213,167,161,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Zoom_Window/Rune.png',0,0,76,78,1,0)
	anim:SetHotSpot(38,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Rune',anim,148,50,155,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/door.png',0,0,157,329,1,0)
	anim:SetHotSpot(78,164)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('door',anim,250,416,90,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/light_from_door.png',0,0,543,768,1,0)
	anim:SetHotSpot(271,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('light_from_door',anim,271,386,91,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/24_Dolls/Zone_Main/Layers/Layer_Doll.png',0,0,233,290,1,0)
	anim:SetHotSpot(116,145)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Doll',anim,116,496,95,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_rune',anim,148,266,167,0,6,5)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
