dofile('data/Scripts/Scenes/Common.lua');
dofile('data/Scripts/Scenes/Animations/05_OutOfCave_Animations.lua');

------------------------------------------------------------------------------
--
function OnSceneLoad(restoringFromSave)
	InitGameState();

	play_field = playField;
    LoadData();
	play_field = nil;

    RootZoomZone = CreateZoomZone('RootZoomZone', nil, 
                                   nil, 0.0, 
                                   nil, 0.0,
							{'RootBackground',
							 'backpack',
							 'backpackClosed',
							 'eatenFlowerLeaves',
							 'nest',
							 'actZoneDinoRoot',
							 'dinoIdleCyclic',
							 'dinoEatingAnimation',
							 'dinoIdleEye',

							 'actZoneRopeAndMinigame',
							 'actZoneFlowerPlace',
							 'actZoneFlowerRoot',
							 'actZoneFlower',
							 'actZoneCrystals',
							 'actZoneNest',
							 'actZoneBackpack',

							 'LayerOverPterodactyl',
							 'LayerOverApple',
							 'layerOverArrow',
							 'LayerOverBackpack',
							 'LayerOverBanana',
							 'LayerOverBoomerang',
							 'LayerOverBow',
							 'LayerOverEgg',
							 'LayerOverFlower',
							 'LayerOverIdol',
							 'LayerOverNest',
							 'LayerOverPineapple',
							 'LayerOverPlate',
							 'LayerOverSkull',
							 'LayerOverSword',
							 'LayerOverTorch',

							 'Egg',
							 'Flower',
							 'Knife',
							 'Pick',
							 'Rope',
							 'Ruby',

							 'Rope_onPlace',
							 'Egg_onPlace',
							 'Flower_onPlace',

							 'apple',
							 'appleCore',
							 'archer',
							 'arrow',
							 'axe',
							 'bag',
							 'banana',
							 'bananaSkin',
							 'basket',
							 'bone',
							 'book',
							 'boomerang',
							 'boots',
							 'bow',
							 'carrot',
							 'catapult',
							 'chain',
							 'coconut',
							 'feather',
							 'frog',
							 'garland',
							 'goblet',
							 'grapes',
							 'handbell',
							 'helmet',
							 'idol',
							 'jug',
							 'lizard',
							 'mask',
							 'pawprint',
							 'pineapple',
							 'plate',
							 'ring',
							 'shovel',
							 'skull',
							 'spider',
							 'strobile',
							 'sword',
							 'wheel'},

							{
							 'Pick',
							 'Ruby',
							 'Rope_onPlace',
							 'Egg_onPlace',
							 'Flower_onPlace'});

if (restoringFromSave == false) then
    AddRandomTasks(true, MISC_TASK_COUNT_24,
		CreateTask('apple'),
		CreateTask('appleCore'),
		CreateTask('archer'),
		CreateTask('arrow'),
		CreateTask('axe'),
		CreateTask('bag'),
		CreateTask('banana'),
		CreateTask('bananaSkin'),
		CreateTask('basket'),
		CreateTask('bone'),
		CreateTask('book'),
		CreateTask('boomerang'),
		CreateTask('boots'),
		CreateTask('bow'),
		CreateTask('carrot'),
		CreateTask('catapult'),
		CreateTask('chain'),
		CreateTask('coconut'),
		CreateTask('feather'),
		CreateTask('frog'),
--		CreateTask('garland'),
		CreateTask('goblet'),
		CreateTask('grapes'),
		CreateTask('handbell'),
		CreateTask('helmet'),
		CreateTask('idol'),
		CreateTask('jug'),
		CreateTask('lizard'),
		CreateTask('mask'),
		CreateTask('pawprint'),
		CreateTask('pineapple'),
		CreateTask('plate'),
		CreateTask('ring'),
		CreateTask('shovel'),
		CreateTask('skull'),
		CreateTask('spider'),
		CreateTask('strobile'),
		CreateTask('sword'),
		CreateTask('wheel')
	);

    playField:GetLevelScreen():AddTaskSafe(CreateTask('Pick'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Rope'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Egg'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Knife'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Flower'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Ruby'));
end
                                                       
	CreateToolMap(	{'Pick', 	'actZoneCrystals'},
					{'Rope', 	'actZoneRopeAndMinigame'},
					{'Egg', 	'actZoneNest'},
					{'Knife',	'actZoneFlower'},
					{'Flower',	'actZoneFlowerPlace'},
					{'Ruby',	'actZoneBackpack'});

	SetIconForGameObject(playField:GetObject('apple'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/apple_icon.png');
	SetIconForGameObject(playField:GetObject('appleCore'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/appleCore_icon.png');
	SetIconForGameObject(playField:GetObject('archer'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/archer_icon.png');
	SetIconForGameObject(playField:GetObject('arrow'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/arrow_icon.png');
	SetIconForGameObject(playField:GetObject('axe'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/axe_icon.png');
	SetIconForGameObject(playField:GetObject('bag'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/bag_icon.png');
	SetIconForGameObject(playField:GetObject('banana'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/banana_icon.png');
	SetIconForGameObject(playField:GetObject('bananaSkin'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/bananaSkin_icon.png');
	SetIconForGameObject(playField:GetObject('basket'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/basket_icon.png');
	SetIconForGameObject(playField:GetObject('bone'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/bone_icon.png');
	SetIconForGameObject(playField:GetObject('book'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/book_icon.png');
	SetIconForGameObject(playField:GetObject('boomerang'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/boomerang_icon.png');
	SetIconForGameObject(playField:GetObject('boots'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/boots_icon.png');
	SetIconForGameObject(playField:GetObject('bow'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/bow_icon.png');
	SetIconForGameObject(playField:GetObject('carrot'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/carrot_icon.png');
	SetIconForGameObject(playField:GetObject('catapult'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/catapult_icon.png');
	SetIconForGameObject(playField:GetObject('chain'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/chain_icon.png');
	SetIconForGameObject(playField:GetObject('coconut'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/coconut_icon.png');
	SetIconForGameObject(playField:GetObject('feather'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/feather_icon.png');
	SetIconForGameObject(playField:GetObject('frog'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/frog_icon.png');
	SetIconForGameObject(playField:GetObject('garland'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/garland_icon.png');
  	SetIconForGameObject(playField:GetObject('goblet'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/goblet_icon.png');
	SetIconForGameObject(playField:GetObject('grapes'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/grapes_icon.png');
	SetIconForGameObject(playField:GetObject('handbell'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/handbell_icon.png');
	SetIconForGameObject(playField:GetObject('helmet'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/helmet_icon.png');
	SetIconForGameObject(playField:GetObject('idol'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/idol_icon.png');
	SetIconForGameObject(playField:GetObject('jug'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/jug_icon.png');
	SetIconForGameObject(playField:GetObject('lizard'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/lizard_icon.png');
	SetIconForGameObject(playField:GetObject('mask'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/mask_icon.png');
	SetIconForGameObject(playField:GetObject('pawprint'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/pawprint_icon.png');
	SetIconForGameObject(playField:GetObject('pineapple'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/pineapple_icon.png');
	SetIconForGameObject(playField:GetObject('plate'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/plate_icon.png');
	SetIconForGameObject(playField:GetObject('ring'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/ring_icon.png');
	SetIconForGameObject(playField:GetObject('shovel'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/shovel_icon.png');
	SetIconForGameObject(playField:GetObject('skull'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/skull_icon.png');
	SetIconForGameObject(playField:GetObject('spider'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/spider_icon.png');
	SetIconForGameObject(playField:GetObject('strobile'),	'data/Texture/Scenes/05_OutOfCave/Items/Misc/strobile_icon.png');
	SetIconForGameObject(playField:GetObject('sword'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/sword_icon.png');
	SetIconForGameObject(playField:GetObject('wheel'),		'data/Texture/Scenes/05_OutOfCave/Items/Misc/wheel_icon.png');

	SetIconForGameObject(playField:GetObject('Pick'),		'data/Texture/Scenes/05_OutOfCave/Items/Pick_icon.png');
	SetIconForGameObject(playField:GetObject('Rope'),		'data/Texture/Scenes/05_OutOfCave/Items/Rope_icon.png');
	SetIconForGameObject(playField:GetObject('Egg'),		'data/Texture/Scenes/05_OutOfCave/Items/Egg_icon.png');
	SetIconForGameObject(playField:GetObject('Knife'),		'data/Texture/Scenes/05_OutOfCave/Items/Knife_icon.png');
	SetIconForGameObject(playField:GetObject('Flower'),		'data/Texture/Scenes/05_OutOfCave/Items/Flower_icon.png');
	SetIconForGameObject(playField:GetObject('Ruby'),		'data/Texture/Scenes/05_OutOfCave/Items/Ruby_icon.png');

if (restoringFromSave == false) then
	gameState.dinoRootInitXY = {playField:GetObject('actZoneDinoRoot'):GetX() - 140.0,
								playField:GetObject('actZoneDinoRoot'):GetY()};
	gameState.pteroTimePeriod = 0.01;
	gameState.pteroDuration = 0.0;
	gameState.rubyInitY = playField:GetObject('Ruby'):GetY();
	gameState.rubyDistanceY = 100.0;
	gameState.flowerInitY = playField:GetObject('actZoneFlowerRoot'):GetY();
	gameState.flowerFallDistance = 520.0;

	gameState.pterodactylAnimationDelay = 0.0;

	gameState.pickUsed = false;
	gameState.ropeOnPlace = false;
	gameState.eggOnPlace = false;
	gameState.knifeUsed = false;
	gameState.flowerUsed = false;
	gameState.rubyOnPlace = false;

	gameState.flowerIsMoving = false;
	gameState.flowerPicked = false;
	gameState.flowerIsEaten = false;
	gameState.rubyIsMoving = false;
	gameState.rubyPicked = false;
	gameState.dinoIsEating = false;

	gameState.minigameCompleted = false;
	gameState.allToolsApplied = false;
	gameState.levelCompleted = false;
end

	AssignActiveZonesGlow({function() return gameState.pickUsed; end,		'actZoneCrystals',		'Pick_ghost'},
						  {function() return gameState.ropeOnPlace; end,	'actZoneRopeAndMinigame','Rope_ghost'},
					      {function() return gameState.eggOnPlace; end,		'actZoneNest',			'Egg_ghost'},
						  {function() return gameState.knifeUsed; end,		'actZoneFlower',		'Knife_ghost'},
						  {function() return gameState.flowerUsed;end,		'actZoneFlowerPlace',	'Flower_ghost'},
						  {function() return gameState.rubyOnPlace; end,	'actZoneBackpack',		'Ruby_ghost'});

    ApplyLevelDump(restoringFromSave);
	SetZoneVisible(RootZoomZone, true, false);

	auxSceneInit(restoringFromSave);
	auxProcessToolObjectStateAnCursorType();
end

------------------------------------------------------------------------------
--
function OnSceneFree()
    FreeData();
    StopSound('L05S10');
    StopSound('L05S11');
    StopSound('L05S12');
    StopSound('L05S13');
    StopSound('L05S14');
    StopSound('L05S15');
end

--// Local auxiliary functions - - - - - - - - - - - - - - - - - - - - - - - -
function auxSceneInit(restoringFromSave)
    local initialActions = function()
		ShowLevelIntro(05);
    end
	local regularActions = function()
	    PlaySound('L05S13', true);

		auxAttachInPlace(playField:GetObject('dinoIdleEye'), playField:GetObject('dinoIdleCyclic'));
		auxInitDinoAnimation();
		if (playField:HasObject('Flower') == true) then
		    auxAttachInPlace(playField:GetObject('Flower'), playField:GetObject('actZoneFlowerRoot'));
		end

		auxCreateOutOfCaveAnimations(playField:GetObject('RootBackground'));
		auxPlayOutOfCaveAnimation('Dragonfly1');
		auxPlayOutOfCaveAnimation('CyclicCompGroup');
		
		gameState.pteroTimePeriod = 0.01;
	    gameState.pteroDuration = 0.0;

		gameState.flowerIsMoving = false;
		gameState.rubyIsMoving = false;
		gameState.dinoIsEating = false;
	end

    if (restoringFromSave == false) then
        initialActions();
    end	
    regularActions();

	if (gameState.levelCompleted == true) then
		gameState.levelCompleted = false;
		auxTestLevelCompleteCondition();
	end
end

function auxProcessToolObjectStateAnCursorType()
    assert(gameState.pickUsed ~= nil and
		   gameState.ropeOnPlace ~= nil and
		   gameState.eggOnPlace ~= nil and
		   gameState.knifeUsed ~= nil and
		   gameState.flowerUsed ~= nil and
		   gameState.rubyOnPlace ~= nil and
		   true);

	if (gameState.pickUsed == true) then
		if (gameState.rubyIsMoving == false and playField:HasObject('Ruby') == true) then
			if (gameState.rubyPicked == false) then
				playField:GetObject('Ruby'):SetY(gameState.rubyInitY);
				RootZoomZone.HideObject('Ruby');
			else
				playField:GetObject('Ruby'):SetY(gameState.rubyInitY + gameState.rubyDistanceY);
				RootZoomZone.UnhideObject('Ruby');
			end
		end
		gameState.customCursors['actZoneCrystals'] = nil;
	else
		gameState.customCursors['actZoneCrystals'] = {'CursorArms'};
	end

	if (gameState.ropeOnPlace == true) then
		RootZoomZone.UnhideObject('Rope_onPlace');
		gameState.customCursors['actZoneRopeAndMinigame'] = nil;
		if (gameState.minigameCompleted == false) then
			gameState.customCursors['actZoneRopeAndMinigame'] = {'CursorNavigation', -10 /180.0*M_PI};
		else
			gameState.customCursors['actZoneRopeAndMinigame'] = nil;
		end
	else
		RootZoomZone.HideObject('Rope_onPlace');
		gameState.customCursors['actZoneRopeAndMinigame'] = {'CursorArms'};
	end

	if (gameState.eggOnPlace == true) then
		RootZoomZone.UnhideObject('Egg_onPlace');
		gameState.customCursors['actZoneNest'] = nil;
	else
		RootZoomZone.HideObject('Egg_onPlace');
		gameState.customCursors['actZoneNest'] = {'CursorArms'};
	end

	if (gameState.knifeUsed == true) then
		if (gameState.flowerIsMoving == false) then
			if (gameState.flowerPicked == false) then
				playField:GetObject('actZoneFlowerRoot'):SetY(gameState.flowerInitY);
			else
				playField:GetObject('actZoneFlowerRoot'):SetY(gameState.flowerInitY + gameState.flowerFallDistance);
			end
		end
		gameState.customCursors['actZoneFlower'] = nil;
	else
		gameState.customCursors['actZoneFlower'] = {'CursorArms'};
	end

	if (gameState.dinoIsEating == false) then
		if (gameState.flowerUsed == true) then
			if (gameState.flowerIsEaten == true) then
				RootZoomZone.HideObject('Flower_onPlace');
			else
				RootZoomZone.UnhideObject('Flower_onPlace');
			end
			gameState.customCursors['actZoneFlowerPlace'] = nil;
		else
			gameState.customCursors['actZoneFlowerPlace'] = {'CursorArms'};
		end
	end

	if (gameState.rubyOnPlace == true) then
		RootZoomZone.HideObject('backpack');
		gameState.customCursors['actZoneBackpack'] = nil;
	else
		RootZoomZone.UnhideObject('backpack');
		gameState.customCursors['actZoneBackpack'] = {'CursorArms'};
	end
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxInitDinoAnimation()
    auxStopAnimation('dinoEatingAnimation', HGEANIM_FWD);
    auxStopAnimation('dinoIdleCyclic', HGEANIM_FWD + HGEANIM_LOOP);

    local AssignWigglingEffector = function(obj)
            assert(obj ~= nil);

        	local duration = 8.0;
	        local distance = 16.0;
	        local objY = obj:GetY();

            local eff = CreateAnimationEffector();
            eff:AttachTo(obj);
	        eff:SetMode(_ANIM_FWD + _ANIM_LOOP);

            eff:SetKey(_TRACK_Y, 0.0, 				objY);
            eff:SetKey(_TRACK_Y, duration * 1.0/8.0,objY + distance * 0.1);
            eff:SetKey(_TRACK_Y, duration * 2.0/8.0,objY + distance * 0.5);
            eff:SetKey(_TRACK_Y, duration * 3.0/8.0,objY + distance * 0.9);
            eff:SetKey(_TRACK_Y, duration * 4.0/8.0,objY + distance * 1.0);
            eff:SetKey(_TRACK_Y, duration * 5.0/8.0,objY + distance * 0.9);
            eff:SetKey(_TRACK_Y, duration * 6.0/8.0,objY + distance * 0.5);
            eff:SetKey(_TRACK_Y, duration * 7.0/8.0,objY + distance * 0.1);
            eff:SetKey(_TRACK_Y, duration, 			objY);

            eff:Play();
          end
	local objRoot = playField:GetObject('actZoneDinoRoot');
	local objIdle = playField:GetObject('dinoIdleCyclic');
	local objEating = playField:GetObject('dinoEatingAnimation'); 
	auxAttachInPlace(objIdle, objRoot);
	auxAttachInPlace(objEating, objRoot);
	AssignWigglingEffector(objIdle);
	AssignWigglingEffector(objEating);
	
	objRoot:SetX(gameState.dinoRootInitXY[1]);
	auxSwitchDinoAnimation(true);
end
function auxSwitchDinoAnimation(idleActive)
	if (idleActive == true) then
		gameState.dinoIsEating = false;
	    playField:GetObject('dinoIdleCyclic'):GetAnimation():Play();
		RootZoomZone.UnhideObject('dinoIdleCyclic', 0.01);
	    playField:GetObject('dinoEatingAnimation'):GetAnimation():Stop();
		RootZoomZone.HideObject('dinoEatingAnimation', 0.01);
	else
	    playField:GetObject('dinoEatingAnimation'):GetAnimation():Play();
		RootZoomZone.UnhideObject('dinoEatingAnimation', 0.01);
	    playField:GetObject('dinoIdleCyclic'):GetAnimation():Stop();
		RootZoomZone.HideObject('dinoIdleCyclic', 0.01);
		PlaySound('L05S10');
	end
end
function auxEatFlower()
	gameState.flowerIsEaten = true;
	RootZoomZone.HideObject('Flower_onPlace');
end
function auxPlayDinoEatingAnimation()
    local obj = playField:GetObject('actZoneDinoRoot');
    
    local duration = 8.0;
    local delay = 3.0;
    local dx, dy = 140.0, 180.0;
    local objX, objY = gameState.dinoRootInitXY[1], gameState.dinoRootInitXY[2];

	obj:SetXY(objX, objY);

    local eff = CreateAnimationEffector();
    eff:AttachTo(obj);
    eff:SetMode(_ANIM_FWD);

    eff:SetKey(_TRACK_X, 0.0, 				    objX);
    eff:SetKey(_TRACK_Y, 0.0, 				    objY);
    eff:SetKey(_TRACK_X, duration/2.0, 		    objX + dx);
    eff:SetKey(_TRACK_Y, duration/2.0, 		    objY + dy);
    eff:SetKey(_TRACK_X, duration/2.0 + delay, 	objX + dx);
    eff:SetKey(_TRACK_Y, duration/2.0 + delay, 	objY + dy);
    eff:SetKey(_TRACK_X, duration + delay, 	    objX);
    eff:SetKey(_TRACK_Y, duration + delay, 	    objY);

    eff:Play();

	gameState.flowerIsEaten = true;
	gameState.dinoIsEating = true;
	RootZoomZone.UnhideObject('Flower_onPlace');

	TimerDoString('auxSwitchDinoAnimation(false);',duration/2.0, playField:GetTimer());
	TimerDoString('auxEatFlower();', duration/2.0 + delay/4.0, playField:GetTimer());
	TimerDoString('auxSwitchDinoAnimation(true);', duration/2.0 + delay, playField:GetTimer());
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxUpdatePretodactylAnimation(dt)
	gameState.pteroTimePeriod = gameState.pteroTimePeriod + dt;
	if gameState.pteroTimePeriod > gameState.pteroDuration then
		gameState.pteroTimePeriod = gameState.pteroTimePeriod - gameState.pteroDuration;

        local obj = playField:GetObject('pterodactylAnimation');
        local rndScale = math.random();
        local rndYStartPos = 220.0 + math.random() * 200.0;
        local rndYEndPos = rndYStartPos + (1.0 - math.random()*2.0)* 100.0;
        local duration = 1.0 / (rndScale + 0.2) * 1.5;
        local fromRightToLeft = (math.random() > 0.5) and true or false;

        gameState.pteroDuration = duration;
		obj:SetScale(0.5 + rndScale * 0.5);
		obj:SetScaleX((fromRightToLeft==true and 1.0 or -1.0) * (0.5 + rndScale * 0.5));
--        obj:GetAnimation():SetColor('0xFF888888'); --// '0xFF888888' = {255, 136, 136, 136}
        local cR = 136 + rndScale * (216 - 136);
        local cG = 136 + rndScale * (177 - 136);
        local cB = 136 + rndScale * (44 - 136);
		obj:GetAnimation():SetColor(ColorARGB(255, cR, cG, cB));   --// '0xFFD8B12C' = {255, 216, 177, 44}
--		'0xFF8EA2A8'

    	eff = CreateAnimationEffector();
    	eff:AttachTo(obj);
    	eff:SetKey(_TRACK_X, 0.0,       fromRightToLeft==true and 500.0 or -100.0);
    	eff:SetKey(_TRACK_Y, 0.0,       rndYStartPos);
    	eff:SetKey(_TRACK_X, duration,  fromRightToLeft==true and -100.0 or 500.0);
    	eff:SetKey(_TRACK_Y, duration,  rndYEndPos);
    	eff:Play();
	end
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxDisableRubyMovingFlag()
	gameState.rubyIsMoving = false;
end
function auxPlayRubyFallAnimation()
	local duration = 0.5;

	gameState.rubyIsMoving = true;
	TimerDoString('auxDisableRubyMovingFlag();', duration, playField:GetTimer());

	local objRuby = playField:GetObject('Ruby');
	objRuby:SetY(gameState.rubyInitY);
	RootZoomZone.UnhideObject('Ruby');

	objRuby:Move(0.0, gameState.rubyDistanceY, duration);
	objRuby:Rotate(4.0*M_PI, duration);

	gameState.customCursors['actZoneCrystals'] = nil;
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxDisableFlowerMovingFlag()
	gameState.flowerIsMoving = false;
end
function auxPlayFlowerFallAnimation()
	local duration = 1.0;

	gameState.flowerIsMoving = true;
	TimerDoString('auxDisableFlowerMovingFlag();', duration, playField:GetTimer());
	TimerDoString('PlaySound(\'L05S15\');', duration, playField:GetTimer());

	local obj = playField:GetObject('actZoneFlowerRoot');
	obj:SetY(gameState.flowerInitY);

	obj:Move(0.0, gameState.flowerFallDistance, duration);
	obj:Rotate(M_TWO_PI, duration);

	gameState.customCursors['actZoneFlower'] = nil;
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxPickupPick()
	RootZoomZone.UnhideObject('Pick', 0.01);
	OnObjectMouseDown(playField:GetObject('Pick'));
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxPlayPterosctylPairAnimation()
	auxPlayOutOfCaveAnimation('Pter_All1');
	TimerDoString('auxPlayOutOfCaveAnimation(\'Pter_All2\');', 3.0 + 2.0*math.random(), playField:GetTimer());
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxUpdatePterodactylPair(dt)
	if (gameState.pterodactylAnimationDelay == 0.0) then
		auxPlayPterosctylPairAnimation();
		gameState.pterodactylAnimationDelay = math.random(30, 60);
	else
		gameState.pterodactylAnimationDelay = (gameState.pterodactylAnimationDelay - dt >= 0.0 and gameState.pterodactylAnimationDelay - dt or 0.0);
	end
end

-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxTestLevelCompleteCondition()
	if (gameState.allToolsApplied == true and
		gameState.levelCompleted == false and
		playField:GetLevelScreen():HasUncompletedTask() == false) then

		gameState.levelCompleted = true;
	--// play outro comix
	TimerDoString('playField:GetLevelScreen():ShowComicScreen(\'Level5Outro\');', 1.0, playField:GetTimer());
		TimerDoString('OnWin();', 2.0, playField:GetTimer());
	end
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

------------------------------------------------------------------------------
--
function OnDialogButtonPress(name, param)
end

------------------------------------------------------------------------------
--
function OnUpdate(dt)
	auxUpdatePretodactylAnimation(dt);
	auxUpdatePterodactylPair(dt);

    DefaultOnUpdate(dt);
end

------------------------------------------------------------------------------
--
function OnWin()
	DefaultOnWin();
end

------------------------------------------------------------------------------
--
function OnObjectMouseEnter(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseEnter(object);
	ActivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseLeave(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseLeave(object);
    DeactivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseDown(object)
    local objectName = object:GetName();
    local isWrongClick = true;

	assert(gameState.activeZone ~= nil and gameState.locker:GetNReferences() > 0);

    if (gameState.lockedObjects[objectName] ~= true) then
        if (gameState.activeZone.HasObject(objectName)) then
            isWrongClick = DefaultOnZoomZoneActiveObjectClick(objectName);

			--// ...
if (objectName == 'actZoneRopeAndMinigame' and 
	gameState.ropeOnPlace == true and 
	gameState.minigameCompleted == false) then

	gameState.minigameCompleted = true;
	auxProcessToolObjectStateAnCursorType();
--	TimerDoString('auxPickupPick();', 0.05, playField:GetTimer());
	auxPickupPick();
    playField:GetLevelScreen():RunMiniGame('data/Scripts/Minigames/Dino.lua');
    isWrongClick = false;
end


	        if (isWrongClick == true and playField:GetLevelScreen():IsTaskObject(objectName)) then
	            auxAttachInPlace(object, playField);
				object:ResetClippingRect();
				--// remove object from zoom-zone which contents it
				assert(gameState.activeZone.objects[objectName] ~= nil);
				gameState.activeZone.objects[objectName] = nil;

                playField:OnObjectFound(object);
                isWrongClick = false;
            end
        else
--			assert(gameState.activeZone ~= RootZoomZone and 
--				   gameState.locker:GetNReferences() > 1 and
--				   'Attempt to close root scene - you have clicked on an object which hasn`t been added to any zoom-zone');
            if (gameState.activeZone ~= RootZoomZone and gameState.locker:GetNReferences() > 1) then
                if (gameState.lockedObjects[gameState.activeZone.activeObject] == nil) then
                    SetZoneVisible(gameState.activeZone, false);
                end
            else
                Log('Lua: OnObjectMouseDown(\''..objectName..'\'): Was made click on object which hasn`t been attached to any zoom-zone');
            end
        end --// if (gameState.activeZone.HasObject(...
    end --// if (gameState.lockedObjects[...

	--// Tips - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	if (objectName == 'actZoneNest' and gameState.eggOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_NEST_TIP1'), GetTextString('LEVEL5_NEST_TIP2'));
	elseif (objectName == 'actZoneFlowerPlace' and gameState.flowerUsed == false) then
		playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_FLOWER_PLACE_TIP'));
	elseif (objectName == 'actZoneFlower' and gameState.knifeUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_FLOWER_TIP1'), GetTextString('LEVEL5_FLOWER_TIP2'), GetTextString('LEVEL5_FLOWER_TIP3'));
	elseif (objectName == 'dinoIdleCyclic' and gameState.flowerUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_DINO_TIP1'), GetTextString('LEVEL5_DINO_TIP2'));
	elseif (objectName == 'actZoneRopeAndMinigame' and gameState.ropeOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_ROPE_TIP1'), GetTextString('LEVEL5_ROPE_TIP2'));
	elseif (objectName == 'actZoneCrystals' and gameState.pickUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_RUBY_TIP'));
	elseif (objectName == 'actZoneBackpack' and gameState.rubyOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_BACKPACK_TIP1'));
	else
	    playField:GetLevelScreen():HideTip();
	end
	--//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

    DefaultOnObjectClick(object, isWrongClick, not playField:GetLevelScreen():IsTipShown());
    DefaultOnObjectMouseEnter(object);
end

------------------------------------------------------------------------------
--
function OnObjectMouseUp(object)
end

------------------------------------------------------------------------------
--
function OnObjectFound(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	if (objectName == 'Knife') then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL5_KNIFE_FOUND_TIP'));
	end
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	local objectMustBeHighlighted = DefaultOnObjectFound(object);
	return objectMustBeHighlighted;
end

------------------------------------------------------------------------------
--
function OnToolFound(tool)
end

------------------------------------------------------------------------------
--
function CanToolBeApplied(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local canToolBeApplied = true;
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	canToolBeApplied = DefaultCanToolBeApplied(tool, object);
	return canToolBeApplied;
end

------------------------------------------------------------------------------
--
function OnToolApply(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local toolApplied = false;

	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	if (toolName == 'Pick' and objName == gameState.toolMap[toolName]) then
    	gameState.pickUsed = true;
		gameState.rubyPicked = true;
		toolApplied = true;
		auxPlayRubyFallAnimation();
		PlaySound('L05S12');
	end
	if (toolName == 'Rope' and objName == gameState.toolMap[toolName]) then
		toolApplied = true;
		HighlightGameObject(playField:GetObject('actZoneRopeAndMinigame'), playField:GetTimer(), 3.0);
		HighlightGameObject(playField:GetObject('actZoneRopeAndMinigame'), playField:GetTimer(), 2.5);
    	gameState.ropeOnPlace = true;
	end
	if (toolName == 'Egg' and objName == gameState.toolMap[toolName]) then
		toolApplied = true;
    	gameState.eggOnPlace = true;
	end
	if (toolName == 'Knife' and objName == gameState.toolMap[toolName]) then
    	gameState.knifeUsed = true;
		gameState.flowerPicked = true;
		toolApplied = true;
		auxPlayFlowerFallAnimation();
		PlaySound('L05S11');
	end
	if (toolName == 'Flower' and (objName == gameState.toolMap[toolName] or
								  objName == 'dinoIdleCyclic')) then
    	gameState.flowerUsed = true;
		toolApplied = true;
		auxPlayDinoEatingAnimation();
	end
	if (toolName == 'Ruby' and objName == gameState.toolMap[toolName]) then
    	gameState.rubyOnPlace = true;
		toolApplied = true;
	end
	if (not toolApplied) then
	    playField:GetLevelScreen():ShowTip(GetTextString('WRONG_ITEM_APPLIED_TIP1'),
										   GetTextString('WRONG_ITEM_APPLIED_TIP2'));
	end


	if (gameState.pickUsed == true and
		gameState.ropeOnPlace == true and
		gameState.eggOnPlace == true and
		gameState.knifeUsed == true and
		gameState.flowerUsed == true and
		gameState.rubyOnPlace == true and
		gameState.allToolsApplied == false) then

		gameState.allToolsApplied = true;
		if (playField:GetLevelScreen():HasUncompletedTask() == true) then
		    playField:GetLevelScreen():ShowTip(GetTextString('HAVE_TO_FIND_ITEMS_MSG1'),
											   GetTextString('HAVE_TO_FIND_ITEMS_MSG2'));
		else
			auxTestLevelCompleteCondition();
		end
	end

	auxProcessToolObjectStateAnCursorType();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DefaultOnObjectMouseEnter(object);
	if (toolApplied == true) then
	    DeactivateActiveZoneDeactivatedGlow(object:GetName());
	end
	return toolApplied;
end

------------------------------------------------------------------------------
--
function OnObjectReachPanel(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	auxTestLevelCompleteCondition();
end

------------------------------------------------------------------------------
--
function OnButtonPress(zoneName)
    DefaultOnButtonPress(zoneName);
end

------------------------------------------------------------------------------
--
function OnMouseMove(prevMousePos, currentMousePos)
end

------------------------------------------------------------------------------
--
function OnSetTool(tool)
end

------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData()
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('RootBackground',anim,512,384,97,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverPterodactyl.png',0,0,624,514,1,0)
	anim:SetHotSpot(312,257)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverPterodactyl',anim,310,373,99,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/backpack.png',0,0,88,96,1,0)
	anim:SetHotSpot(44,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('backpack',anim,775,524,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/backpackClosed.png',0,0,88,96,1,0)
	anim:SetHotSpot(44,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('backpackClosed',anim,775,524,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/eatenFlowerLeaves.png',0,0,140,52,1,0)
	anim:SetHotSpot(70,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('eatenFlowerLeaves',anim,364,714,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/nest.png',0,0,142,89,1,0)
	anim:SetHotSpot(71,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('nest',anim,983,98,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/dinoIdleCyclic.png',0,0,414,270,9,5)
	anim:SetHotSpot(621,405)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('dinoIdleCyclic',anim,620,682,108,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/dinoEatingAnimation.png',0,0,414,270,9,8)
	anim:SetHotSpot(621,405)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('dinoEatingAnimation',anim,619,682,109,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/dinoIdleEye.png',0,0,22,30,18,5)
	anim:SetHotSpot(11,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('dinoIdleEye',anim,293,407,109,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneDinoRoot',anim,12,376,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/pterodactylAnimation.png',0,0,95,142,8,12)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFD8B160')
	play_field:CreateObject('pterodactylAnimation',anim,223,322,98,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneRopeAndMinigame',anim,519,278,105,30,1.3,1.8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneFlowerPlace',anim,376,706,103,0,0.8,0.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneFlower',anim,862,123,106,0,0.7,0.8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneFlowerRoot',anim,861,127,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneCrystals',anim,487,555,106,0,0.8,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneNest',anim,977,91,106,0,0.9,0.7)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneBackpack',anim,769,510,106,0,0.7,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverApple.png',0,0,32,12,1,0)
	anim:SetHotSpot(16,6)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverApple',anim,548,761,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/layerOverArrow.png',0,0,24,36,1,0)
	anim:SetHotSpot(12,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('layerOverArrow',anim,476,463,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverBackpack.png',0,0,92,63,1,0)
	anim:SetHotSpot(46,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBackpack',anim,774,559,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverBanana.png',0,0,68,28,1,0)
	anim:SetHotSpot(34,14)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBanana',anim,708,63,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverBoomerang.png',0,0,52,22,1,0)
	anim:SetHotSpot(26,11)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBoomerang',anim,299,437,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverBow.png',0,0,31,39,1,0)
	anim:SetHotSpot(15,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBow',anim,849,560,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverEgg.png',0,0,73,35,1,0)
	anim:SetHotSpot(36,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverEgg',anim,746,743,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverFlower.png',0,0,51,110,1,0)
	anim:SetHotSpot(25,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverFlower',anim,885,144,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverIdol.png',0,0,129,57,1,0)
	anim:SetHotSpot(64,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverIdol',anim,959,754,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverNest.png',0,0,92,133,1,0)
	anim:SetHotSpot(46,66)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverNest',anim,991,137,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverPineapple.png',0,0,84,82,1,0)
	anim:SetHotSpot(42,41)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverPineapple',anim,261,627,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverPlate.png',0,0,84,35,1,0)
	anim:SetHotSpot(42,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverPlate',anim,637,750,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverSkull.png',0,0,70,52,1,0)
	anim:SetHotSpot(35,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverSkull',anim,494,141,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverSword.png',0,0,41,54,1,0)
	anim:SetHotSpot(20,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverSword',anim,465,522,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Layers/LayerOverTorch.png',0,0,37,62,1,0)
	anim:SetHotSpot(18,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverTorch',anim,950,368,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Egg.png',0,0,53,62,1,0)
	anim:SetHotSpot(26,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Egg',anim,739,729,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Flower.png',0,0,59,69,1,0)
	anim:SetHotSpot(29,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Flower',anim,864,124,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Knife.png',0,0,50,98,1,0)
	anim:SetHotSpot(25,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Knife',anim,962,334,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Pick.png',0,0,60,90,1,0)
	anim:SetHotSpot(30,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Pick',anim,556,277,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Rope.png',0,0,47,131,1,0)
	anim:SetHotSpot(23,65)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Rope',anim,972,452,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Ruby.png',0,0,41,48,1,0)
	anim:SetHotSpot(15,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Ruby',anim,507,521,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Rope_onPlace.png',0,0,152,379,1,0)
	anim:SetHotSpot(76,189)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Rope_onPlace',anim,406,470,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Egg_onPlace.png',0,0,138,92,1,0)
	anim:SetHotSpot(69,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Egg_onPlace',anim,986,97,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Flower_onPlace.png',0,0,59,69,1,0)
	anim:SetHotSpot(29,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Flower_onPlace',anim,366,707,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/apple.png',0,0,40,38,1,0)
	anim:SetHotSpot(20,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('apple',anim,542,749,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/appleCore.png',0,0,42,26,1,0)
	anim:SetHotSpot(21,13)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('appleCore',anim,373,661,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/archer.png',0,0,90,73,1,0)
	anim:SetHotSpot(45,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('archer',anim,251,168,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/arrow.png',0,0,78,119,1,0)
	anim:SetHotSpot(39,59)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('arrow',anim,446,417,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/axe.png',0,0,57,104,1,0)
	anim:SetHotSpot(42,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('axe',anim,378,572,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/bag.png',0,0,73,98,1,0)
	anim:SetHotSpot(36,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bag',anim,647,231,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/banana.png',0,0,77,58,1,0)
	anim:SetHotSpot(38,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('banana',anim,677,55,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/bananaSkin.png',0,0,93,39,1,0)
	anim:SetHotSpot(46,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bananaSkin',anim,478,656,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/basket.png',0,0,82,73,1,0)
	anim:SetHotSpot(41,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('basket',anim,615,598,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/bone.png',0,0,80,38,1,0)
	anim:SetHotSpot(40,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bone',anim,428,681,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/book.png',0,0,110,61,1,0)
	anim:SetHotSpot(55,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('book',anim,538,734,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/boomerang.png',0,0,91,48,1,0)
	anim:SetHotSpot(45,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('boomerang',anim,274,441,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/boots.png',0,0,79,56,1,0)
	anim:SetHotSpot(39,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('boots',anim,733,612,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/bow.png',0,0,71,253,1,0)
	anim:SetHotSpot(35,126)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bow',anim,853,490,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/carrot.png',0,0,66,58,1,0)
	anim:SetHotSpot(33,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('carrot',anim,346,206,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/catapult.png',0,0,60,38,1,0)
	anim:SetHotSpot(30,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('catapult',anim,662,649,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/chain.png',0,0,53,175,1,0)
	anim:SetHotSpot(26,87)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chain',anim,794,119,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/coconut.png',0,0,53,50,1,0)
	anim:SetHotSpot(26,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('coconut',anim,767,259,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/feather.png',0,0,74,35,1,0)
	anim:SetHotSpot(37,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('feather',anim,379,750,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/frog.png',0,0,45,46,1,0)
	anim:SetHotSpot(22,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('frog',anim,999,660,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/garland.png',0,0,71,107,1,0)
	anim:SetHotSpot(35,53)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('garland',anim,177,657,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/goblet.png',0,0,68,41,1,0)
	anim:SetHotSpot(34,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('goblet',anim,768,683,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/grapes.png',0,0,77,101,1,0)
	anim:SetHotSpot(38,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('grapes',anim,628,43,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/handbell.png',0,0,41,63,1,0)
	anim:SetHotSpot(20,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('handbell',anim,732,347,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/helmet.png',0,0,68,69,1,0)
	anim:SetHotSpot(34,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('helmet',anim,685,527,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/idol.png',0,0,104,185,1,0)
	anim:SetHotSpot(52,92)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('idol',anim,941,677,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/jug.png',0,0,67,103,1,0)
	anim:SetHotSpot(33,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('jug',anim,572,451,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/lizard.png',0,0,52,74,1,0)
	anim:SetHotSpot(26,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('lizard',anim,1003,289,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/mask.png',0,0,41,96,1,0)
	anim:SetHotSpot(20,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('mask',anim,314,356,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/pawprint.png',0,0,58,38,1,0)
	anim:SetHotSpot(29,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pawprint',anim,301,751,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/pineapple.png',0,0,72,93,1,0)
	anim:SetHotSpot(36,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pineapple',anim,259,598,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/plate.png',0,0,80,63,1,0)
	anim:SetHotSpot(40,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('plate',anim,631,746,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/ring.png',0,0,35,39,1,0)
	anim:SetHotSpot(17,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ring',anim,696,737,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/shovel.png',0,0,57,196,1,0)
	anim:SetHotSpot(28,98)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shovel',anim,647,521,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/skull.png',0,0,51,50,1,0)
	anim:SetHotSpot(25,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('skull',anim,474,126,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/spider.png',0,0,81,67,1,0)
	anim:SetHotSpot(40,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('spider',anim,167,92,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/strobile.png',0,0,51,61,1,0)
	anim:SetHotSpot(25,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('strobile',anim,310,79,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/sword.png',0,0,73,159,1,0)
	anim:SetHotSpot(36,79)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('sword',anim,493,466,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Misc/wheel.png',0,0,93,119,1,0)
	anim:SetHotSpot(46,59)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('wheel',anim,870,616,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Egg_ghost.png',0,0,72,72,1,0)
	anim:SetHotSpot(36,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Egg_ghost',anim,977,78,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Flower_ghost.png',0,0,72,72,1,0)
	anim:SetHotSpot(36,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Flower_ghost',anim,367,706,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Knife_ghost.png',0,0,96,96,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Knife_ghost',anim,872,91,110,50,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Pick_ghost.png',0,0,96,120,1,0)
	anim:SetHotSpot(48,60)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Pick_ghost',anim,516,533,110,-40,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Rope_ghost.png',0,0,180,379,1,0)
	anim:SetHotSpot(90,189)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Rope_ghost',anim,406,469,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_OutOfCave/Items/Ruby_ghost.png',0,0,64,64,1,0)
	anim:SetHotSpot(32,32)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Ruby_ghost',anim,774,471,110,0,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
