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

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

function OnSceneLoad()
	play_field = miniGamePlayField;
    LoadData();
	play_field = nil;

   	miniGameState = {};
   	miniGameState.delayPeriod = 90.0;
   	miniGameState.timeElapsed = 0.0;
   	miniGameState.delayPeriodPassed = false;
   	miniGameState.completed = false;
   	
   	music_volume = GetMusicVolume(GetCurrentMusicName());
	SetMusicVolume(GetCurrentMusicName(), 0.1);
	
	auxLoadDataAndPlayIntro();  
	
	for i = 1,5 do
		auxAttachInPlace(miniGamePlayField:GetObject('totems_green_'..i), miniGamePlayField:GetObject("Podstavka"..i.."_01"), 1);
		miniGamePlayField:GetObject('totems_green_'..i):SetVisible(false);
	end
	
	InitObject();

	TimerDoString('OnShowHelp()', 2.0, miniGamePlayField:GetTimer());
end
function OnSceneFree()
	SetMusicVolume(GetCurrentMusicName(), music_volume);
    FreeData();

	StopSound('L02S01');
	StopSound('L02S02');
	StopSound('L02S03');
	StopSound('L02S04');
end

--// auxiliary functions -----------------------------------------------------
function auxCreateObject(resourceName, objectName)
    assert(miniGameState ~= nil and resourceName ~= '' and objectName ~= '');
    
    if (miniGameState.objects == nil) then
        miniGameState.objects = {};
    end
    
    if (miniGameState.objects[objectName] ~= nil) then
        local object = miniGameState.objects[objectName];
        local anim = object:GetAnimation();
        return object, anim;
    else
        local anim = CreateAnimationByPath(resourceName);
        local object = miniGamePlayField:CreateObject(objectName, anim, 0, 0, 0, 0, 1, 1); 
        miniGameState.objects[objectName] = object;
        return object, anim;
    end
end


function auxLoadDataAndPlayIntro()
PlaySound('L02S01');
TimerDoString('StopSound("L02S01");', 2.3, miniGamePlayField:GetTimer());
--// 										1. " -> '
screen = miniGamePlayField;  		--//	2. +
local anim;					 		--//	3. +
local effector;				 		--//	4. +
local object;                       --//    4. +
--screen:SetDuration(movieDuration);--//	5. -
--//                                        6. CreateAnimationEffector -> CreateAnimationEffectorAE
local zOffset = 0;                  --//    7. +
--// remove assignment lifetime     --//    8. comment lines which begins with -- effector:SetLifeTime(... 
--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

local movieDuration = 2.3;
--screen:SetDuration(movieDuration);
local timeOffset = 1.0;

-- Layer RuchkaR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/RuchkaR_01.png', 'RuchkaR_01');
anim:SetHotSpot(102, 74);
object:SetZ(zOffset + 25);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0, 603);
effector:SetKey(_TRACK_Y, 0, 372);
effector:SetKey(_TRACK_X, 0.86666666666667, 1159);
effector:SetKey(_TRACK_Y, 0.86666666666667, 374);
effector:SetKey(_TRACK_A, 0, 0);
effector:SetKey(_TRACK_A, 0.16666666666667, 0);
effector:SetKey(_TRACK_A, 0.36666666666667, 0.17152730049251);
effector:SetKey(_TRACK_A, 0.5, 0);
effector:SetKey(_TRACK_A, 0.66666666666667, -0.31283600464608);
effector:SetKey(_TRACK_A, 0.8, 0);

effector:PlayAt(timeOffset);


-- Layer DverR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/DverR_01.png','DverR_01');
anim:SetHotSpot(268, 384);
object:SetZ(zOffset + 24);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0, 755);
effector:SetKey(_TRACK_Y, 0, 382);
effector:SetKey(_TRACK_X, 0.86666666666667, 1311);
effector:SetKey(_TRACK_Y, 0.86666666666667, 384);

effector:PlayAt(timeOffset);


-- Layer RuchkaL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/RuchkaL_01.png', 'RuchkaL_01');
anim:SetHotSpot(98.5, 72.5);
object:SetZ(zOffset + 23);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0, 380.5);
effector:SetKey(_TRACK_Y, 0, 374);
effector:SetKey(_TRACK_X, 0.86666666666667, -159.5);
effector:SetKey(_TRACK_Y, 0.86666666666667, 374);
effector:SetKey(_TRACK_A, 0, 0);
effector:SetKey(_TRACK_A, 0.16666666666667, 0);
effector:SetKey(_TRACK_A, 0.36666666666667, -0.174532925);
effector:SetKey(_TRACK_A, 0.5, 0);
effector:SetKey(_TRACK_A, 0.66666666666667, 0.314159265);
effector:SetKey(_TRACK_A, 0.8, 0);

effector:PlayAt(timeOffset);


-- Layer DverL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/DverL_01.png', 'DverL_01');
anim:SetHotSpot(261.5, 384);
object:SetZ(zOffset + 22);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0, 261);
effector:SetKey(_TRACK_Y, 0, 384);
effector:SetKey(_TRACK_X, 0.86666666666667, -279);
effector:SetKey(_TRACK_Y, 0.86666666666667, 384);

effector:PlayAt(timeOffset);


-- Layer Totem5
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Totem5_01.png', 'Totem5');
anim:SetHotSpot(100, 75);
object:SetXY(876, 572);
object:SetZ(zOffset + 21);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Totem4
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Totem4_01.png', 'Totem4');
anim:SetHotSpot(110, 80);
object:SetXY(688, 568);
object:SetZ(zOffset + 20);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Totem3
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Totem3_01.png', 'Totem3');
anim:SetHotSpot(65, 100);
object:SetXY(502, 602);
object:SetZ(zOffset + 19);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Totem2
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Totem2_01.png', 'Totem2');
anim:SetHotSpot(70, 115);
object:SetXY(290, 560);
object:SetZ(zOffset + 18);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Totem1
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Totem1_01.png', 'Totem1');
anim:SetHotSpot(100, 110);
object:SetXY(126, 495);
object:SetZ(zOffset + 17);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG_Layer_R_04
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer_R_04.png', 'BG_Layer_R_04');
anim:SetHotSpot(64, 146.5);
object:SetXY(829, 146.5);
object:SetZ(zOffset + 16);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG_Layer_L_03
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer_L_03.png', 'BG_Layer_L_03');
anim:SetHotSpot(70, 134);
object:SetXY(144, 134);
object:SetZ(zOffset + 15);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG_Layer02
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer02.png', 'BG_Layer02');
anim:SetHotSpot(463.5, 74);
object:SetXY(501, 694);
object:SetZ(zOffset + 14);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1.0);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Chain2_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Chain2_01.png', 'Chain2_01');
anim:SetHotSpot(23, 320);
object:SetZ(zOffset + 13);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0.8, 858);
effector:SetKey(_TRACK_Y, 0.8, 324);
effector:SetKey(_TRACK_X, 1.93333333333333, 858);
effector:SetKey(_TRACK_Y, 1.93333333333333, 460);

effector:PlayAt(timeOffset);


-- Layer Chain1_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Chain1_01.png', 'Chain1_01');
anim:SetHotSpot(23, 320);
object:SetZ(zOffset + 12);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0.8, 112);
effector:SetKey(_TRACK_Y, 0.8, 338);
effector:SetKey(_TRACK_X, 2, 112);
effector:SetKey(_TRACK_Y, 2, 474);

effector:PlayAt(timeOffset);


-- Layer Podstavka3_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka3_01.png', 'Podstavka3_01');
anim:SetHotSpot(94, 135);
object:SetZ(zOffset + 11);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 1, 478);
effector:SetKey(_TRACK_Y, 1, 731);
effector:SetKey(_TRACK_X, 1.7, 478);
effector:SetKey(_TRACK_Y, 1.7, 575);
effector:SetKey(_TRACK_X, 1.86666666666667, 478);
effector:SetKey(_TRACK_Y, 1.86666666666667, 603);

effector:PlayAt(timeOffset);


-- Layer Podstavka4_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka4_01.png', 'Podstavka4_01');
anim:SetHotSpot(94, 135);
object:SetZ(zOffset + 10);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 1.26666666666667, 654);
effector:SetKey(_TRACK_Y, 1.26666666666667, 764);
effector:SetKey(_TRACK_X, 2.26666666666667, 654);
effector:SetKey(_TRACK_Y, 2.26666666666667, 608);
effector:SetKey(_TRACK_X, 3.23333333333333, 654);
effector:SetKey(_TRACK_Y, 3.23333333333333, 636);

effector:PlayAt(timeOffset);


-- Layer Podstavka2_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka2_01.png', 'Podstavka2_01');
anim:SetHotSpot(93, 134);
object:SetZ(zOffset + 9);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 1.13333333333333, 320);
effector:SetKey(_TRACK_Y, 1.13333333333333, 716);
effector:SetKey(_TRACK_X, 1.83333333333333, 320);
effector:SetKey(_TRACK_Y, 1.83333333333333, 560);
effector:SetKey(_TRACK_X, 2, 320);
effector:SetKey(_TRACK_Y, 2, 588);

effector:PlayAt(timeOffset);


-- Layer Podstavka1_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka1_01.png', 'Podstavka1_01');
anim:SetHotSpot(89, 135);
object:SetZ(zOffset + 8);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 1, 172);
effector:SetKey(_TRACK_Y, 1, 770);
effector:SetKey(_TRACK_X, 1.7, 172);
effector:SetKey(_TRACK_Y, 1.7, 614);
effector:SetKey(_TRACK_X, 1.86666666666667, 172);
effector:SetKey(_TRACK_Y, 1.86666666666667, 642);

effector:PlayAt(timeOffset);


-- Layer Podstavka5_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka5_01.png', 'Podstavka5_01');
anim:SetHotSpot(90, 135);
object:SetZ(zOffset + 7);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 1.23333333333333, 806);
effector:SetKey(_TRACK_Y, 1.23333333333333, 736);
effector:SetKey(_TRACK_X, 1.93333333333333, 806);
effector:SetKey(_TRACK_Y, 1.93333333333333, 580);
effector:SetKey(_TRACK_X, 2.1, 806);
effector:SetKey(_TRACK_Y, 2.1, 608);

effector:PlayAt(timeOffset);


-- Layer BG_Layer01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer01.png', 'BG_Layer01');
anim:SetHotSpot(512, 384);
object:SetXY(512, 384);
object:SetZ(zOffset + 6);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Dver01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Dver01.png', 'Dver01');
anim:SetHotSpot(130, 280);
object:SetZ(zOffset + 5);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0, 381);
effector:SetKey(_TRACK_Y, 0, 444);
effector:SetKey(_TRACK_X, 2, 381);
effector:SetKey(_TRACK_Y, 2, 444);

effector:PlayAt(timeOffset);


-- Layer Dver02
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Dver02.png', 'Dver02');
anim:SetHotSpot(135, 275);
object:SetXY(616, 448);
object:SetZ(zOffset + 4);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer ZamokR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/ZamokR_01.png', 'ZamokR_01');
anim:SetHotSpot(101.25, 81.75);
object:SetXY(608, 523);
object:SetZ(zOffset + 3);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer ZamokL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/ZamokL_01.png', 'ZamokL_01');
anim:SetHotSpot(22.75, 82);
object:SetXY(386, 526);
object:SetZ(zOffset + 2);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Mass01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Mass01.png', 'Mass01');
anim:SetHotSpot(70, 355);
object:SetXY(502, 432);
object:SetZ(zOffset + 1);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG01.png', 'BG01');
anim:SetHotSpot(512, 384);
object:SetXY(512, 384);
object:SetZ(zOffset + 0);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 2.23333333333333);
effector:AttachTo(object);


effector:PlayAt(timeOffset);

end

--// auxiliary functions -----------------------------------------------------
function auxPlayOutro()
PlaySound('L02S02');
TimerDoString('StopSound("L02S01");', 1.6, miniGamePlayField:GetTimer());
screen = miniGamePlayField;  		--//	1. +
local anim;					 		--//	2. +
local object;                       --//    3. +
local effector;				 		--//	4. +
local zOffset = 0;                  --//    5. +

local movieDuration = 1.6;
-- screen:SetDuration(movieDuration);
local timeOffset = 0.0;

--[[
-- Layer RuchkaR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/RuchkaR_01.png', 'RuchkaR_01');
anim:SetHotSpot(102, 74);
object:SetXY(117, 366);
object:SetZ(zOffset + 20);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_A, -2.26666666666667, 0);
effector:SetKey(_TRACK_A, -2.1, 0);
effector:SetKey(_TRACK_A, -1.9, 0.17152730049251);
effector:SetKey(_TRACK_A, -1.76666666666667, 0);
effector:SetKey(_TRACK_A, -1.6, -0.31283600464608);
effector:SetKey(_TRACK_A, -1.46666666666667, 0);

effector:PlayAt(timeOffset);

-- Layer DverR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/DverR_01.png', 'DverR_01');
anim:SetHotSpot(268, 384);
object:SetZ(zOffset + 19);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, -2.26666666666667, 755);
effector:SetKey(_TRACK_Y, -2.26666666666667, 382);
effector:SetKey(_TRACK_X, -1.4, 1311);
effector:SetKey(_TRACK_Y, -1.4, 384);

effector:PlayAt(timeOffset);


-- Layer RuchkaL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/RuchkaL_01.png', 'RuchkaL_01');
anim:SetHotSpot(98.5, 72.5);
object:SetXY(382.5, 372);
object:SetZ(zOffset + 18);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_A, -2.26666666666667, 0);
effector:SetKey(_TRACK_A, -2.1, 0);
effector:SetKey(_TRACK_A, -1.9, -0.174532925);
effector:SetKey(_TRACK_A, -1.76666666666667, 0);
effector:SetKey(_TRACK_A, -1.6, 0.314159265);
effector:SetKey(_TRACK_A, -1.46666666666667, 0);

effector:PlayAt(timeOffset);

-- Layer DverL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/DverL_01.png', 'DverL_01');
anim:SetHotSpot(261.5, 384);
object:SetZ(zOffset + 17);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, -2.26666666666667, 261);
effector:SetKey(_TRACK_Y, -2.26666666666667, 384);
effector:SetKey(_TRACK_X, -1.4, -279);
effector:SetKey(_TRACK_Y, -1.4, 384);

effector:PlayAt(timeOffset);
--]]


-- Layer BG_Layer_R_04
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer_R_04.png', 'BG_Layer_R_04');
anim:SetHotSpot(64, 146.5);
object:SetXY(829, 146.5);
object:SetZ(zOffset + 16);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG_Layer_L_03
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer_L_03.png', 'BG_Layer_L_03');
anim:SetHotSpot(70, 134);
object:SetXY(144, 134);
object:SetZ(zOffset + 15);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer BG_Layer02
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer02.png', 'BG_Layer02');
anim:SetHotSpot(463.5, 74);
object:SetXY(501, 694);
object:SetZ(zOffset + 40);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
--object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Chain2_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Chain2_01.png', 'Chain2_01');
anim:SetHotSpot(23, 320);
object:SetZ(zOffset + 13);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.46666666666667, 858);
effector:SetKey(_TRACK_Y, -1.46666666666667, 324);
effector:SetKey(_TRACK_X, -0.33333333333333, 858);
effector:SetKey(_TRACK_Y, -0.33333333333333, 460);
--]]
effector:SetKey(_TRACK_X, 0.53333333333333, 858);
effector:SetKey(_TRACK_Y, 0.53333333333333, 460);
effector:SetKey(_TRACK_X, 1.53333333333333, 858);
effector:SetKey(_TRACK_Y, 1.53333333333333, 460);
effector:SetKey(_TRACK_X, 1.56666666666667, 858);
effector:SetKey(_TRACK_Y, 1.56666666666667, 466);
effector:SetKey(_TRACK_X, 2.53333333333333, 856);
effector:SetKey(_TRACK_Y, 2.53333333333333, 322);

effector:PlayAt(timeOffset);


-- Layer Chain1_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Chain1_01.png', 'Chain1_01');
anim:SetHotSpot(23, 320);
object:SetZ(zOffset + 12);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.46666666666667, 112);
effector:SetKey(_TRACK_Y, -1.46666666666667, 338);
effector:SetKey(_TRACK_X, -0.26666666666667, 112);
effector:SetKey(_TRACK_Y, -0.26666666666667, 474);
--]]
effector:SetKey(_TRACK_X, 0.6, 112);
effector:SetKey(_TRACK_Y, 0.6, 474);
effector:SetKey(_TRACK_X, 1.53333333333333, 114);
effector:SetKey(_TRACK_Y, 1.53333333333333, 470);
effector:SetKey(_TRACK_X, 1.56666666666667, 114);
effector:SetKey(_TRACK_Y, 1.56666666666667, 480.5);
effector:SetKey(_TRACK_X, 2.53333333333333, 112);
effector:SetKey(_TRACK_Y, 2.53333333333333, 336.5);

effector:PlayAt(timeOffset);


-- Layer Podstavka3_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka3_01.png', 'Podstavka3_01');
anim:SetHotSpot(94, 135);
object:SetZ(zOffset + 11);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.26666666666667, 478);
effector:SetKey(_TRACK_Y, -1.26666666666667, 731);
effector:SetKey(_TRACK_X, -0.56666666666667, 478);
effector:SetKey(_TRACK_Y, -0.56666666666667, 575);
effector:SetKey(_TRACK_X, -0.4, 478);
effector:SetKey(_TRACK_Y, -0.4, 603);
effector:SetKey(_TRACK_X, -0.13333333333333, 478);
effector:SetKey(_TRACK_Y, -0.13333333333333, 603);
--]]
effector:SetKey(_TRACK_X, 0.0, 478);
effector:SetKey(_TRACK_Y, 0.0, 700);
effector:SetKey(_TRACK_X, 2.56666666666667, 476);
effector:SetKey(_TRACK_Y, 2.56666666666667, 1075);

effector:PlayAt(timeOffset);


-- Layer Podstavka4_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka4_01.png', 'Podstavka4_01');
anim:SetHotSpot(94, 135);
object:SetZ(zOffset + 10);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1, 654);
effector:SetKey(_TRACK_Y, -1, 764);
effector:SetKey(_TRACK_X, -0.3, 654);
effector:SetKey(_TRACK_Y, -0.3, 608);
effector:SetKey(_TRACK_X, -0.13333333333333, 654);
effector:SetKey(_TRACK_Y, -0.13333333333333, 636);
--]]
effector:SetKey(_TRACK_X, 0.0, 654);
effector:SetKey(_TRACK_Y, 0.0, 700);
effector:SetKey(_TRACK_X, 2.56666666666667, 652);
effector:SetKey(_TRACK_Y, 2.56666666666667, 1088);

effector:PlayAt(timeOffset);


-- Layer Podstavka2_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka2_01.png', 'Podstavka2_01');
anim:SetHotSpot(93, 134);
object:SetZ(zOffset + 9);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.13333333333333, 320);
effector:SetKey(_TRACK_Y, -1.13333333333333, 716);
effector:SetKey(_TRACK_X, -0.43333333333333, 320);
effector:SetKey(_TRACK_Y, -0.43333333333333, 560);
effector:SetKey(_TRACK_X, -0.26666666666667, 320);
effector:SetKey(_TRACK_Y, -0.26666666666667, 588);
--]]
effector:SetKey(_TRACK_X, 0, 320);
effector:SetKey(_TRACK_Y, 0, 700);
effector:SetKey(_TRACK_X, 2.56666666666667, 320);
effector:SetKey(_TRACK_Y, 2.56666666666667, 1040);

effector:PlayAt(timeOffset);


-- Layer Podstavka1_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka1_01.png', 'Podstavka1_01');
anim:SetHotSpot(89, 135);
object:SetZ(zOffset + 8);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.26666666666667, 172);
effector:SetKey(_TRACK_Y, -1.26666666666667, 770);
effector:SetKey(_TRACK_X, -0.56666666666667, 172);
effector:SetKey(_TRACK_Y, -0.56666666666667, 614);
effector:SetKey(_TRACK_X, -0.4, 172);
effector:SetKey(_TRACK_Y, -0.4, 642);
--]]
effector:SetKey(_TRACK_X, 0, 172);
effector:SetKey(_TRACK_Y, 0, 700);
effector:SetKey(_TRACK_X, 2.56666666666667, 170);
effector:SetKey(_TRACK_Y, 2.56666666666667, 1048);

effector:PlayAt(timeOffset);


-- Layer Podstavka5_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Podstavka5_01.png', 'Podstavka5_01');
anim:SetHotSpot(90, 135);
object:SetZ(zOffset + 7);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

--[[
effector:SetKey(_TRACK_X, -1.03333333333333, 806);
effector:SetKey(_TRACK_Y, -1.03333333333333, 736);
effector:SetKey(_TRACK_X, -0.33333333333333, 806);
effector:SetKey(_TRACK_Y, -0.33333333333333, 580);
effector:SetKey(_TRACK_X, -0.16666666666667, 806);
effector:SetKey(_TRACK_Y, -0.16666666666667, 608);
--]]
effector:SetKey(_TRACK_X, 0, 806);
effector:SetKey(_TRACK_Y, 0, 700);
effector:SetKey(_TRACK_X, 2.56666666666667, 802);
effector:SetKey(_TRACK_Y, 2.56666666666667, 1030);

effector:PlayAt(timeOffset);


-- Layer BG_Layer01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG_Layer01.png', 'BG_Layer01');
anim:SetHotSpot(512, 384);
object:SetXY(512, 384);
object:SetZ(zOffset + 6);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);


effector:PlayAt(timeOffset);


-- Layer Dver01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Dver01.png', 'Dver01');
anim:SetHotSpot(130, 280);
object:SetZ(zOffset + 5);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0.1, 381);
effector:SetKey(_TRACK_Y, 0.1, 444);
effector:SetKey(_TRACK_X, 0.4, 249);
effector:SetKey(_TRACK_Y, 0.4, 444);
effector:SetKey(_TRACK_X, 0.6666666666667, 263);
effector:SetKey(_TRACK_Y, 0.46666666666667, 444);

effector:PlayAt(timeOffset);


-- Layer Dver02
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Dver02.png', 'Dver02');
anim:SetHotSpot(135, 275);
object:SetZ(zOffset + 4);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0.1, 616);
effector:SetKey(_TRACK_Y, 0.1, 448);
effector:SetKey(_TRACK_X, 0.36666666666667, 758);
effector:SetKey(_TRACK_Y, 0.36666666666667, 448);
effector:SetKey(_TRACK_X, 0.46666666666667, 742);
effector:SetKey(_TRACK_Y, 0.46666666666667, 448);

effector:PlayAt(timeOffset);


-- Layer ZamokR_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/ZamokR_01.png', 'ZamokR_01');
anim:SetHotSpot(101.25, 81.75);
object:SetXY(608, 523);
object:SetZ(zOffset + 3);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_A, 0.53333333333333, 0);
effector:SetKey(_TRACK_A, 0.73333333333333, 1.08222544085629);
effector:SetKey(_TRACK_A, 0.8, 0.86583260461558);

effector:PlayAt(timeOffset);


-- Layer ZamokL_01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/ZamokL_01.png', 'ZamokL_01');
anim:SetHotSpot(22.75, 82);
object:SetXY(386, 526);
object:SetZ(zOffset + 2);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_A, 0.56666666666667, 0);
effector:SetKey(_TRACK_A, 0.76666666666667, -0.93266990390994);
effector:SetKey(_TRACK_A, 0.83333333333333, -0.77773309443949);

effector:PlayAt(timeOffset);


-- Layer Mass01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/Mass01.png', 'Mass01');
anim:SetHotSpot(70, 355);
object:SetZ(zOffset + 1);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:SetKey(_TRACK_X, 0.9, 502);
effector:SetKey(_TRACK_Y, 0.9, 432);
effector:SetKey(_TRACK_X, 0.96666666666667, 502);
effector:SetKey(_TRACK_Y, 0.96666666666667, 436);
effector:SetKey(_TRACK_X, 2.5, 500);
effector:SetKey(_TRACK_Y, 2.5, 158);
effector:SetKey(_TRACK_X, 2.53333333333333, 500);
effector:SetKey(_TRACK_Y, 2.53333333333333, 164);

effector:PlayAt(timeOffset);


-- Layer BG01
object, anim = auxCreateObject('data/Texture/Minigames/Platforms/BG01.png', 'BG01');
anim:SetHotSpot(512, 384);
object:SetXY(512, 384);
object:SetZ(zOffset + 0);
object:SetScaleX(1);
object:SetScaleY(1);
object:SetAngle(0);
object:SetOpacity(1);

effector = CreateAnimationEffectorAE();
-- effector:SetLifeTime(0, 1.56666666666667);
effector:AttachTo(object);

effector:PlayAt(timeOffset);

  	TimerDoString("miniGameState.completed = true;", movieDuration, miniGamePlayField:GetTimer());
end


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

function PlaceToProp(Totem, Prop)
	local effector = CreateAnimationEffectorAE();
	effector:AttachTo(Prop.Obj);

	local bottom = 700 + (Totem.Mass - Prop.MassNeed) * 10;
	
	effector:SetKey(_TRACK_Y, 0.0, Prop.Pos.y);
	effector:SetKey(_TRACK_X, 0.0, Prop.Pos.x);
	effector:SetKey(_TRACK_Y, 0.5, bottom);
	effector:SetKey(_TRACK_X, 0.5, Prop.Pos.x);
	
	for i = 1, 4 do                                                         
		effector:SetKey(_TRACK_Y, 0.5 + i / 10, bottom - 8 + math.random(16));
		--effector:SetKey(_TRACK_Y, 0.7 + i / 20, bottom - 1 + math.random(3));
	end
	
	effector:SetKey(_TRACK_X, 1.3, Prop.Pos.x);
	effector:SetKey(_TRACK_Y, 1.3, bottom);
	
	effector:PlayAt(0.0);
end

function TakeFromProp(Prop)
	local effector = CreateAnimationEffectorAE();
	effector:AttachTo(Prop.Obj);
	
	effector:SetKey(_TRACK_Y, 0.0, Prop.Obj:GetY());
	effector:SetKey(_TRACK_X, 0.0, Prop.Pos.x);
	effector:SetKey(_TRACK_Y, 0.5, Prop.Pos.y);
	effector:SetKey(_TRACK_X, 0.5, Prop.Pos.x);
	effector:SetKey(_TRACK_Y, 0.8, Prop.Pos.y + 10);
	effector:SetKey(_TRACK_Y, 1.0, Prop.Pos.y );
	
	effector:PlayAt(0.0);
end

function auxAttachInPlace(object, parentObject, z)
	local scrX,scrY = object:GetScrX(), object:GetScrY();
	object:AttachTo(parentObject);
	object:SetScrXY(scrX, scrY);
	object:SetZ(z);
end

function InitObject()
	Needs = {Vector(175, 523), Vector(319, 468), Vector(478, 483), Vector(656, 516), Vector(811, 490)};
	local Masses = {5, 1, 2, 4, 3}
	local NeedMasses = {1, 5, 4, 2, 3}
	local PropPos = {Vector(172, 642), Vector(320, 588), Vector(478, 603), Vector(654, 636), Vector(806, 608)}

	--инициализируем тотемы
	Objects= {};
	
	for i = 1,5 do
		Objects[i] = {};
		Objects[i].Obj = miniGamePlayField:GetObject("Totem"..i);
		Objects[i].Name = Objects[i].Obj:GetName();
		Objects[i].StartPos = Objects[i].Obj:GetPosition();
		Objects[i].NeedPos = Needs[i];
		Objects[i].Active = true;
		Objects[i].Index = i;
		Objects[i].Mass = Masses[i];
		Objects[i].Prop = nil;
		Objects[i].Inplace = false
		Objects[i].Z = Objects[i].Obj:GetZ();
		
		local anim = CreateAnimation('data/Texture/Minigames/Platforms/Totem_Match01.png',0,0,96,96,120,60)
		anim:SetHotSpot(48,48)
		anim:SetBlendMode(0)
		anim:SetColor('0xFFFFFFFF')
		miniGamePlayField:CreateObject('Totem_Match01_'..i,anim, Objects[i].StartPos.x, Objects[i].StartPos.y--[[ - (Objects[i].Obj:GetAnimation():GetWidth() / 2 + 40)]], 100, 0, 1.5, 1.5)
		anim:SetMode(HGEANIM_NOLOOP + HGEANIM_FWD);
		anim:Stop();
		miniGamePlayField:IgnoreOnTestPoint('Totem_Match01_'..i);
		auxAttachInPlace(miniGamePlayField:GetObject('Totem_Match01_'..i), Objects[i].Obj, 2);
	end
	
	--инициализируем подставки
	Props = {}
	for i = 1,5 do
		Props[i] = {}
		Props[i].Obj = miniGamePlayField:GetObject("Podstavka"..i.."_01");
		Props[i].MassNeed = NeedMasses[i];
		Props[i].Pos = PropPos[i];
		Props[i].Index = i;
		Props[i].Active = true; 
		Props[i].Set = false;
	end
end

function StartDrag(object)
	if(object.Active == true) then
		auxAttachInPlace(object.Obj, miniGamePlayField, 2);
		DragObject = object;
		DragObject.Obj:SetZ(150);
		
		if(DragObject.Prop ~= nil) then
			miniGamePlayField:GetObject("totems_green_"..DragObject.Prop.Index):SetVisible(false);
			TimerDoString('Props['..DragObject.Prop.Index..'].Active = true',  1.1, miniGamePlayField:GetTimer());
			TakeFromProp(DragObject.Prop);
			DragObject.Prop.Set = false;
			DragObject.Prop = nil;
		end
	end
end

function StopDrag()
	if(DragObject ~= nil) then
		local Prop = GetProp(DragObject);
		if(Prop ~= nil) then

			DragObject.Obj:Move(Needs[Prop.Index].x - DragObject.Obj:GetX(), Needs[Prop.Index].y - DragObject.Obj:GetY() - DragObject.Obj:GetAnimation():GetHeight() / 2, 0.2);
			DragObject.Active = false;
			Prop.Active = false;
			DragObject.Prop = Prop;
			PlaySound('L02S04');
			
			if(Prop.MassNeed == DragObject.Mass) then
				Prop.Set = true;
				DragObject.Inplace = true
				TimerDoString('PlaySound("L02S03")', 1.6, miniGamePlayField:GetTimer());
				TimerDoString('miniGamePlayField:GetObject("totems_green_'..Prop.Index..'"):SetVisible(true);', 1.6, miniGamePlayField:GetTimer());
				TimerDoString('miniGamePlayField:GetObject("Totem_Match01_'..DragObject.Index..'"):GetAnimation():Play()', 1.6, miniGamePlayField:GetTimer());
			end
			
			TimerDoString('auxAttachInPlace(Objects['..DragObject.Index..'].Obj, miniGamePlayField:GetObject("Podstavka'..Prop.Index..'_01"), 3)', 0.3, miniGamePlayField:GetTimer());
			TimerDoString('PlaceToProp(Objects['..DragObject.Index..'], Props['..Prop.Index..'])', 0.3, miniGamePlayField:GetTimer());
			TimerDoString('Objects['..DragObject.Index..'].Active = true', 1.5, miniGamePlayField:GetTimer());
			DragObject.Obj:SetZ(DragObject.Z);
			
			if(IsComplited()) then
				TimerDoString('auxPlayOutro()', 1.2, miniGamePlayField:GetTimer());
				miniGameState.completed = true
				auxShowButton(true);
			end
		else
			DragObject.Obj:SetZ(100);
			DragObject.Obj:Move(DragObject.StartPos.x - DragObject.Obj:GetX(), DragObject.StartPos.y - DragObject.Obj:GetY(), 0.2);
		end
		DragObject = nil;
	end
end

function GetObjectByName(ObjName)
	for i = 1,5 do
		if(ObjName == Objects[i].Name) then
			return Objects[i];
		end
	end
	
	return nil;
end

function GetProp(TotemObj)
	for i = 1,5 do
		if(math.abs(TotemObj.Obj:GetX() - Needs[i].x) < 100 and TotemObj.Obj:GetY() - Needs[i].y < 20 and TotemObj.Obj:GetY() - Needs[i].y > -300 and Props[i].Active == true) then
			return Props[i];
		end
	end
	
	return nil;
end

function IsComplited()
	for i = 1,5 do
		if(Props[i].Set == false) then
			return false;
		end
	end
	
	return true;
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 == false and 
        miniGameState.delayPeriodPassed == false and miniGameState.timeElapsed > miniGameState.delayPeriod) then
        miniGameState.delayPeriodPassed = true;
        auxShowButton(false);
    end
end

function OnShowHelp()
	miniGamePlayField:GetLevelScreen():ShowDialog(500, 300, GetTextString('MINIGAME_TOTEMS_HELP'), GetTextString('MINIGAME_HELP_DIALOG_TITLE'));
end

function OnObjectMouseDown(object)
    local objectName = object:GetName();

	local Obj = GetObjectByName(objectName);
	if(Obj ~= nil and not miniGameState.completed) then
	    if not Obj.Inplace then
		    StartDrag(Obj)
		end
	end
end
function OnObjectMouseUp(object)
	StopDrag();
end

function OnObjectRightMouseDown(object)
end
function OnObjectRightMouseUp(object)
end

function OnMouseMove(previousPos, currentPos)
	if(DragObject ~= nil) then
		DragObject.Obj:SetXY(currentPos.x, currentPos.y);
	end	
end

function OnObjectMouseEnter(object)
end
function OnObjectMouseLeave(object)
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/Platforms/totems_green.png',0,0,156,20,1,0)
	anim:SetHotSpot(78,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('totems_green_1',anim,174,645,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Platforms/totems_green.png',0,0,156,20,1,0)
	anim:SetHotSpot(78,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('totems_green_2',anim,319,591,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Platforms/totems_green.png',0,0,156,20,1,0)
	anim:SetHotSpot(78,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('totems_green_3',anim,478,606,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Platforms/totems_green.png',0,0,156,20,1,0)
	anim:SetHotSpot(78,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('totems_green_4',anim,653,638,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Platforms/totems_green.png',0,0,156,20,1,0)
	anim:SetHotSpot(78,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('totems_green_5',anim,806,612,101,0,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
