dofile('data/Scripts/Minigames/minigameScreen.lua');
-- miniGameScreen

------------------------------------------------------------------------------

--Количество елементов пазла
PAZZLE_ELEM_AMOUNT = 9;

-- тип пазла
-- 1. менять можно дюбые
-- 2. менять можно только соседние
PAZZLE_TYPE = 2;

--колличество защелок
LOCK_AMOUNT = 12;

-- Статус игры
-- 1. Сбор пазла

function OnSceneLoad()
	play_field = miniGamePlayField;
    LoadData();
	play_field = nil;
    
    miniGameState = {};
   	miniGameState.delayPeriod = 90.0;
   	miniGameState.timeElapsed = 0.0;
   	miniGameState.delayPeriodPassed = false;
   	miniGameState.completed = false;
   	miniGameState.active = true   

    GAME_STATUS = 1
    
    miniGamePlayField:IgnoreOnTestPoint("plann2");
    miniGamePlayField:IgnoreOnTestPoint("1l");
    miniGamePlayField:IgnoreOnTestPoint("1n");
    miniGamePlayField:IgnoreOnTestPoint("1p");
    miniGamePlayField:IgnoreOnTestPoint("1v");
    miniGamePlayField:IgnoreOnTestPoint("c1");
    
    miniGamePlayField:IgnoreOnTestPoint("zakr p");
    miniGamePlayField:IgnoreOnTestPoint("zakr l");
    miniGamePlayField:IgnoreOnTestPoint("zakr v");
    miniGamePlayField:IgnoreOnTestPoint("zakr n");
    
	miniGamePlayField:IgnoreOnTestPoint("shtir1");
    miniGamePlayField:IgnoreOnTestPoint("shtir2");
    miniGamePlayField:IgnoreOnTestPoint("shtir3");
    
	miniGamePlayField:IgnoreOnTestPoint("shtir1l");
    miniGamePlayField:IgnoreOnTestPoint("shtir2l");
    miniGamePlayField:IgnoreOnTestPoint("shtir3l");
    
	miniGamePlayField:IgnoreOnTestPoint("shtir1n");
    miniGamePlayField:IgnoreOnTestPoint("shtir2n");
    miniGamePlayField:IgnoreOnTestPoint("shtir3n");
    
	miniGamePlayField:IgnoreOnTestPoint("shtir1p");
    miniGamePlayField:IgnoreOnTestPoint("shtir2p");
    miniGamePlayField:IgnoreOnTestPoint("shtir3p");
    
    miniGamePlayField:GetObject("complete_button"):SetVisible(false)

    for i = 1, LOCK_AMOUNT do
		miniGamePlayField:GetObject("radial_glow_"..i):SetVisible(false);
		miniGamePlayField:GetObject("act_zone"..i):SetVisible(false);
		miniGamePlayField:IgnoreOnTestPoint('radial_glow_'..i);
    end
    
    PazzleElem = {};
    PazzleElemPos = {};
    
    local ActiveFlag = {};
    
    for i = 1, PAZZLE_ELEM_AMOUNT do
		PazzleElem[i] = miniGamePlayField:GetObject("f"..i);
		PazzleElemPos[i] = PazzleElem[i]:GetPosition();
		ActiveFlag[i] = false;
    end
    
    for i = 1, PAZZLE_ELEM_AMOUNT do
		local Index;
		repeat
			 Index = math.random(PAZZLE_ELEM_AMOUNT);
		until ActiveFlag[Index] == false;
		
		ActiveFlag[Index] = true;
		PazzleElem[i]:SetXY(PazzleElemPos[Index].x, PazzleElemPos[Index].y);
	end
	
	TimerDoString('OnShowHelp()', 0.5, miniGamePlayField:GetTimer());
end

function OnSceneFree()
    FreeData()
end

--// auxiliary functions -----------------------------------------------------
--// ...
function auxInitSecondGame()
	ObjectLock = {};
	ObjectNeededFlag = {};
	ObjectFlag = {};
	
	for i = 1,LOCK_AMOUNT do
		ObjectLock[i] = miniGamePlayField:GetObject("act_zone"..i);
		miniGamePlayField:GetObject(ObjectLock[i]:GetName()):SetVisible(true);
    end
    
    for i = 1,4 do
		ObjectNeededFlag[i] = {};
		ObjectFlag[i] = {};
		repeat
			for j = 1,3 do
				ObjectNeededFlag[i][j] = math.random(2) - 1; 
				ObjectFlag[i][j] = 0;
			end
		until ObjectNeededFlag[i][0] == 1 or ObjectNeededFlag[i][1] == 1 or ObjectNeededFlag[i][2] == 1
	end
	
	-- Animation
	miniGamePlayField.active = false
	miniGamePlayField:GetObject("complete_button"):SetVisible(true)
	miniGamePlayField:GetObject("complete_button"):GetAnimation():SetBlendMode(0)	
	
	but_anim = CreateAnimationEffector();
    but_anim:AttachTo(miniGamePlayField:GetObject("complete_button"));
    but_anim:SetMode(_ANIM_PINGPONG);
    
    but_anim:SetKey(_TRACK_O, 0, 1);
    but_anim:SetKey(_TRACK_O, 0.3, 0.2);
    but_anim:Play()
    
    TimerDoString('miniGamePlayField:GetObject("complete_button"):GetAnimation():SetBlendMode(2);', 1.2, miniGamePlayField:GetTimer())
    TimerDoString('but_anim:Stop();', 1.2, miniGamePlayField:GetTimer())
    TimerDoString('miniGamePlayField.active = true;', 1.2, miniGamePlayField:GetTimer())
    
    TimerDoString('OnShowHelp()', 1.2, miniGamePlayField:GetTimer());
	
	LockedAmount = 0;
end

function auxFinishFirstGame()
	GAME_STATUS = 2;
	
	for i = 1, PAZZLE_ELEM_AMOUNT do
		PazzleElemPos[i] = nil;
	end

	PazzleElemPos = nil;
	
	auxInitSecondGame();
end

function auxGetObjectIndex(array, object)
	for i = 1,LOCK_AMOUNT do
		if(array[i]:GetName() == object:GetName()) then
			return i;
		end
	end
	
	return 0;
end

--Нажание на собранный пазл
function auxBigButtonDown()
	for i = 1,PAZZLE_ELEM_AMOUNT do
		PazzleElem[i]:SetXY(PazzleElem[i]:GetX() + 2, PazzleElem[i]:GetY() + 2);
	end
	miniGamePlayField:GetObject("complete_button"):SetXY(miniGamePlayField:GetObject("complete_button"):GetX() + 2, miniGamePlayField:GetObject("complete_button"):GetY() + 2)
	
	for i = 1,LOCK_AMOUNT do
		miniGamePlayField:GetObject("radial_glow_"..i):SetVisible(false);
	end
	
	--совпала первая комбинация
	if (ObjectFlag[1][1] == ObjectNeededFlag[1][1] and ObjectFlag[1][2] == ObjectNeededFlag[1][2] and ObjectFlag[1][3] == ObjectNeededFlag[1][3]) then
		for i = 1,3 do
			miniGamePlayField:GetObject("shtir"..i):Move(0.0, -55.0, 0.2);
			miniGamePlayField:IgnoreOnTestPoint("act_zone"..i);
		end
		LockedAmount = LockedAmount + 1;
		PlaySound('L24S00')
	end
	
	--совпала вторая комбинация
	if (ObjectFlag[2][1] == ObjectNeededFlag[2][1] and ObjectFlag[2][2] == ObjectNeededFlag[2][2] and ObjectFlag[2][3] == ObjectNeededFlag[2][3]) then
		for i = 1,3 do
			miniGamePlayField:GetObject("shtir"..i.."p"):Move(55.0, 0.0, 0.2);
			miniGamePlayField:IgnoreOnTestPoint("act_zone"..(i + 3));
		end
		LockedAmount = LockedAmount + 1;
		PlaySound('L24S00')
	end
	
	--совпала третья комбинация
	if (ObjectFlag[3][1] == ObjectNeededFlag[3][1] and ObjectFlag[3][2] == ObjectNeededFlag[3][2] and ObjectFlag[3][3] == ObjectNeededFlag[3][3]) then
		for i = 1,3 do
			miniGamePlayField:GetObject("shtir"..i.."n"):Move(0.0, 55.0, 0.2);
			miniGamePlayField:IgnoreOnTestPoint("act_zone"..(i + 6));
		end
		LockedAmount = LockedAmount + 1;
		PlaySound('L24S00')
	end
	
	--совпала четвертая комбинация
	if (ObjectFlag[4][1] == ObjectNeededFlag[4][1] and ObjectFlag[4][2] == ObjectNeededFlag[4][2] and ObjectFlag[4][3] == ObjectNeededFlag[4][3]) then
		for i = 1,3 do
			miniGamePlayField:GetObject("shtir"..i.."l"):Move(-55.0, 0.0, 0.2);
			miniGamePlayField:IgnoreOnTestPoint("act_zone"..(i + 9));
		end
		LockedAmount = LockedAmount + 1;
		PlaySound('L24S00')
	end
	
	for i = 1,4 do
		for j = 1,3 do
			ObjectFlag[i][j] = 0;
		end
	end
	
	PlaySound('L24S04')
	
	if(LockedAmount == 4) then
		miniGameState.completed = true;
		for i = 1, PAZZLE_ELEM_AMOUNT do
			miniGamePlayField:IgnoreOnTestPoint(PazzleElem[i]:GetName())
			miniGamePlayField:IgnoreOnTestPoint("complete_button")
			auxShowButton(miniGameState.completed)
		end
	end
end

function CreateTorchFireFibrillationEffector(object)
	local duration = 0.35;

	fireFibrillationEffector = CreateAnimationEffector();
	fireFibrillationEffector:AttachTo(object);
	fireFibrillationEffector:SetMode(_ANIM_LOOP);

	fireFibrillationEffector:SetKey(_TRACK_O, 0.0, 0.8);
	fireFibrillationEffector:SetKey(_TRACK_O, duration *1.0/4.0, 0.6);
	fireFibrillationEffector:SetKey(_TRACK_O, duration *2.0/4.0, 0.8);
	fireFibrillationEffector:SetKey(_TRACK_O, duration *3.0/4.0, 0.6);
	fireFibrillationEffector:SetKey(_TRACK_O, duration *4.0/4.0, 0.8);

	fireFibrillationEffector:Play();
end

function OnFirstGameComplite()
	for i = 1, PAZZLE_ELEM_AMOUNT do
	    local dx = math.abs(PazzleElem[i]:GetX() - PazzleElemPos[i].x);
        local dy = math.abs(PazzleElem[i]:GetY() - PazzleElemPos[i].y);
        
        if(dx > 2 or dy > 2) then
--		if (PazzleElem[i]:GetX() ~= PazzleElemPos[i].x or PazzleElem[i]:GetY() ~= PazzleElemPos[i].y)  then
			return false;
		end
	end
	
	return true;
end

function auxPazzleDown(object)
	if (FirstActivElem == nil) then
		FirstActivElem = object
		FirstActivElem:GetAnimation():SetColor("0x80FFFFFF");
		PlaySound('L24S03')
	else
		if(PAZZLE_TYPE == 1) then
			auxPazzleTypeOneDown(object);
		else
			auxPazzleTypeTwoDown(object);
		end
	end
end

--это если менять можно любые с любыми
function auxPazzleTypeOneDown(object)
	local Pos = FirstActivElem:GetPosition();
	FirstActivElem:GetAnimation():SetColor("0xFFFFFFFF");
	FirstActivElem:SetXY(object:GetX(), object:GetY());
	object:SetXY(Pos.x, Pos.y);
	FirstActivElem = nil;
	PlaySound('L24S02')
	if (OnFirstGameComplite()) then
		auxFinishFirstGame();
	end
end

--Это если менять можно только соседние
function auxPazzleTypeTwoDown(object)
	local Index1 = auxGetObjectIndex(PazzleElem, object);
	local Index2 = auxGetObjectIndex(PazzleElem, FirstActivElem);
	
	local x1 = object:GetX(); 
	local y1 = object:GetY();
	local x2 = FirstActivElem:GetX(); 
	local y2 = FirstActivElem:GetY();
	
    local dx = math.abs(x1 - x2);
	local dy = math.abs(y1 - y2);
	
	if(dx >= 45 and dx <=47 and dy <= 2) or  (dx <= 0 and dy >= 45 and dy <= 47)  then
	
--	if(math.abs(x1 - x2) == 46 and math.abs(y1 - y2) == 0) or  (math.abs(x1 - x2) == 0 and math.abs(y1 - y2) == 45)  then
		local Pos = FirstActivElem:GetPosition();
		FirstActivElem:GetAnimation():SetColor("0xFFFFFFFF");
		FirstActivElem:SetXY(object:GetX(), object:GetY());
		object:SetXY(Pos.x, Pos.y);
		FirstActivElem = nil;
		PlaySound('L24S02')
		if (OnFirstGameComplite()) then
			auxFinishFirstGame();
		end
	else
		FirstActivElem:GetAnimation():SetColor("0xFFFFFFFF");
		FirstActivElem = object
		FirstActivElem:GetAnimation():SetColor("0x80FFFFFF");
	end
end

function auxLockDown(object)
	if(string.sub(object:GetName(), 1, 1) == "a") then
		local Index = auxGetObjectIndex(ObjectLock, object);
		if(ObjectFlag[math.floor((Index - 1) / 3) + 1][Index - math.floor((Index - 1) / 3) * 3] == 0) then
			miniGamePlayField:GetObject("radial_glow_"..Index):SetVisible(true);
			CreateTorchFireFibrillationEffector(miniGamePlayField:GetObject("radial_glow_"..Index));
			ObjectFlag[math.floor((Index - 1) / 3) + 1][Index - math.floor((Index - 1) / 3) * 3] = 1;
		else
			miniGamePlayField:GetObject("radial_glow_"..Index):SetVisible(false);
			ObjectFlag[math.floor((Index - 1) / 3) + 1][Index - math.floor((Index - 1) / 3) * 3] = 0;
		end
		PlaySound('L24S01')
	else
		if(string.sub(object:GetName(), 1, 1) == "f") then
			auxBigButtonDown();
			ButtonDown = true;
		elseif object:GetName() == "complete_button" then
		    auxBigButtonDown();
			ButtonDown = true;
		end
	end
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function OnUpdate(dt)
	miniGameState.timeElapsed = miniGameState.timeElapsed + dt;
	auxUpdateProgressBar(miniGameState.timeElapsed > miniGameState.delayPeriod and 1.0 or miniGameState.timeElapsed / miniGameState.delayPeriod);
    if ((miniGameState.completed or miniGameState.timeElapsed > miniGameState.delayPeriod) and  miniGameState.delayPeriodPassed == false)  then
        miniGameState.delayPeriodPassed = true;
        auxShowButton(miniGameState.completed);
    end
end

function OnShowHelp()
    if GAME_STATUS == 1 then
        miniGamePlayField:GetLevelScreen():ShowDialog(500, 300, GetTextString('MINIGAME_LOCK_1_HELP'), GetTextString('MINIGAME_HELP_DIALOG_TITLE'));
    elseif GAME_STATUS == 2 then
        miniGamePlayField:GetLevelScreen():ShowDialog(500, 300, GetTextString('MINIGAME_LOCK_2_HELP'), GetTextString('MINIGAME_HELP_DIALOG_TITLE'));
    end
end

function OnObjectMouseDown(object)
    if miniGamePlayField.active == false then
        return nil
    end

	if(GAME_STATUS == 1) then
		auxPazzleDown(object)
	elseif (GAME_STATUS == 2) then
		auxLockDown(object);
	end
end

function OnObjectMouseUp(object)
    if miniGamePlayField.active == false then
        return nil
    end

	if(ButtonDown ~= nil and ButtonDown == true) then
		for i = 1,PAZZLE_ELEM_AMOUNT do
			PazzleElem[i]:SetXY(PazzleElem[i]:GetX() - 2, PazzleElem[i]:GetY() - 2);
		end
		miniGamePlayField:GetObject("complete_button"):SetXY(miniGamePlayField:GetObject("complete_button"):GetX() - 2, miniGamePlayField:GetObject("complete_button"):GetY() - 2)
		ButtonDown = false;
	end
end

function OnObjectRightMouseDown(object)
end

function OnObjectRightMouseUp(object)
end

function OnMouseMove(previousPos, currentPos)
end

function OnObjectMouseEnter(object)
    if miniGamePlayField.active == false then
        return nil
    end
    
    if object:GetName() == "complete_button" then
        object:GetAnimation():SetBlendMode(0)
    end
end

function OnObjectMouseLeave(object)
    if miniGamePlayField.active == false then
        return nil
    end
    
    if object:GetName() == "complete_button" then
        object:GetAnimation():SetBlendMode(2)
    end
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/Minigames/Lock/plann2.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('plann2',anim,512,384,99,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/1l.png',0,0,89,149,1,0)
	anim:SetHotSpot(44,74)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('1l',anim,288,475,300,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/1n.png',0,0,149,89,1,0)
	anim:SetHotSpot(74,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('1n',anim,533,722,300,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/1p.png',0,0,100,158,1,0)
	anim:SetHotSpot(50,79)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('1p',anim,785,476,300,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/1v.png',0,0,149,89,1,0)
	anim:SetHotSpot(74,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('1v',anim,532,227,300,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f1.png',0,0,46,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f1',anim,488,430,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f2.png',0,0,46,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f2',anim,534,430,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f3.png',0,0,47,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f3',anim,580,430,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f4.png',0,0,47,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f4',anim,488,475,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f5.png',0,0,46,47,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f5',anim,534,475,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f6.png',0,0,46,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f6',anim,580,475,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f7.png',0,0,47,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f7',anim,488,520,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f8.png',0,0,46,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f8',anim,534,520,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/f9.png',0,0,47,46,1,0)
	anim:SetHotSpot(23,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('f9',anim,580,520,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/zakr p.png',0,0,90,167,1,0)
	anim:SetHotSpot(45,83)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('zakr p',anim,652,475,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/zakr n.png',0,0,161,90,1,0)
	anim:SetHotSpot(80,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('zakr n',anim,532,595,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/zakr l.png',0,0,88,169,1,0)
	anim:SetHotSpot(44,84)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('zakr l',anim,417,476,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/zakr v.png',0,0,154,89,1,0)
	anim:SetHotSpot(77,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('zakr v',anim,533,356,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/c1.png',0,0,188,184,1,0)
	anim:SetHotSpot(94,92)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('c1',anim,536,475,300,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir1.png',0,0,32,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir1',anim,479,296,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir2.png',0,0,33,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir2',anim,534,297,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir3.png',0,0,32,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir3',anim,588,296,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir1l.png',0,0,119,39,1,0)
	anim:SetHotSpot(59,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir1l',anim,357,426,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir2l.png',0,0,119,38,1,0)
	anim:SetHotSpot(59,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir2l',anim,357,480,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir3l.png',0,0,119,39,1,0)
	anim:SetHotSpot(59,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir3l',anim,359,535,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir1n.png',0,0,32,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir1n',anim,481,654,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir2n.png',0,0,33,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir2n',anim,535,655,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir3n.png',0,0,32,115,1,0)
	anim:SetHotSpot(16,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir3n',anim,589,655,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir1p.png',0,0,120,39,1,0)
	anim:SetHotSpot(60,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir1p',anim,712,424,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir2p.png',0,0,120,38,1,0)
	anim:SetHotSpot(60,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir2p',anim,713,479,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/shtir3p.png',0,0,120,39,1,0)
	anim:SetHotSpot(60,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shtir3p',anim,713,536,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_1',anim,477,356,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_2',anim,532,357,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_3',anim,583,349,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_4',anim,651,417,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_5',anim,653,472,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_6',anim,652,526,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_7',anim,583,598,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_8',anim,531,597,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_9',anim,480,592,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_10',anim,412,528,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_11',anim,409,479,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFF0000')
	play_field:CreateObject('radial_glow_12',anim,415,422,400,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('act_zone1',anim,479,349,501,0,0.4,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('act_zone2',anim,534,348,500,0,0.4,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('act_zone3',anim,589,349,500,0,0.4,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('act_zone4',anim,664,418,500,0,0.6,0.4)
	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('act_zone5',anim,661,475,500,0,0.6,0.4)
	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('act_zone6',anim,662,530,500,0,0.6,0.4)
	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('act_zone7',anim,585,604,500,0,0.4,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('act_zone8',anim,533,602,500,0,0.4,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('act_zone9',anim,478,604,500,0,0.4,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('act_zone10',anim,407,528,500,0,0.6,0.4)
	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('act_zone11',anim,407,473,500,0,0.6,0.4)
	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('act_zone12',anim,409,417,500,0,0.6,0.4)
	local anim = CreateAnimation('data/Texture/Minigames/Lock/complete_button.PNG',0,0,137,137,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('complete_button',anim,534,475,101,0,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
