dofile('data/Scenes/Minigames/award_race_movie.lua')

local date = os.date('*t')
math.randomseed(os.clock() + date.sec + date.min + date.hour + date.day + date.month + date.year)

function OnSceneLoad(screen)
	--play_field.game_state = game_state
    LoadData(screen)
    game_state = {}    
    
    StopMusic('menu')
    --local pf = play_field
    --local level = pf:GetLevelScreen()
    game_state.custom_cursors = {}
    game_state.locked_objects = {}
    game_state.locker = ReferenceCounter()
    game_state.active_zone = nil
    game_state.inventory_zones = {}
    game_state.active_objects = {}
    game_state.screen = screen;
    game_state.timer = screen:GetTimer()
    game_state.game_over = false;
    
	AddMiniGamesGUI_Race(screen);
	
	game_state.gallop_sound = nil;
	
	game_state.HELP_STRING = "HELP_MINIGAME_AWARD"
	
	show_win_text = false;
	
	StartPos = {}
	StartPos[1] = {151, 384}
	StartPos[2] = {116, 465}
	StartPos[3] = {108, 555}
	StartPos[4] = {74, 668}
	
	FinishPos = {760, 775, 790, 805}

	FacePos = {172, 242, 306, 370}
	
	StartFlag = {false, false, false, false}
	
	won_way = 0;
	
	money_amount = 100;
	money_win = 0;
	
	stake = {0, 0, 0, 0};
 
    Flag = screen:GetObject('Flag');
    Flag:SetXY(-100, -100);
     
    complete_game = false;
    break_horse = false;
     
    Objects = {}
     
    for i = 1, 4 do
		Objects[i] = {}
		Objects[i].Entity = screen:GetObject('run_'..i);
		Objects[i].Entity:GetAnimation():Stop();
		
		Objects[i].EntityBreak = screen:GetObject('fall_'..i);
		Objects[i].EntityBreak:GetAnimation():Stop();
		Objects[i].EntityBreak:SetVisible(false);
		
		Objects[i].Winner = screen:GetObject('winer_'..i);
    end
    
    Objects[1].Face = screen:GetObject('kon_a')
    Objects[2].Face = screen:GetObject('kon_b')
    Objects[3].Face = screen:GetObject('kon_d')
    Objects[4].Face = screen:GetObject('kon_c')
    
    InitilizationGame();
    
    Composition = createCompositionBega()
    Composition:AttachTo(screen);
	Composition:Stop();
	Composition:SetDestroysOnEnd(false);
	
	--AddSheriffEyeLogic(screen)
	
	InitPanel()
	game_state.screen:GetObject("panel_mg"):SetX(-138);
	TimerDoString('game_state.screen:GetObject("panel_mg"):Move(250, 0, 1.0);', 0.5, game_state.screen:GetTimer());
	TimerDoString('PlayIntro()', 0.5, game_state.screen:GetTimer());
	
	game_state.screen:SetLayer(2)
	InitCashAmountText();
	InitStake1Text();
	InitStake2Text();
	InitStake3Text();
	InitStake4Text();
	
	InitWinnerText();
	
	InitFinishText();
end

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

function InitilizationGame()
	game_state.screen:GetObject("panel_mg"):SetX(112);
	for i = 1, 4 do
		Objects[i].Entity:GetAnimation():Stop();
		Objects[i].Entity:GetAnimation():SetFrame(0);
		Objects[i].Entity:SetVisible(true);
		Objects[i].EntityBreak:GetAnimation():Stop();
		Objects[i].EntityBreak:SetVisible(false);
		Objects[i].BreakFlag = false;
		
		local rand = 0;
		repeat
			rand = math.random(4);
		until StartFlag[rand] == false
		
		StartFlag[rand] = true;
		Objects[i].Entity:SetXY(StartPos[rand][1], StartPos[rand][2])
		Objects[i].Entity:SetZ(100 + (rand - 1) * 2);
		Objects[i].Winner:SetVisible(false);
		Objects[i].Way = rand;
		Objects[i].Face:AttachTo(game_state.screen);
		Objects[i].Face:SetXY(88, FacePos[rand]);
		auxAttachInPlace(Objects[i].Face, game_state.screen:GetObject('panel_mg'));
	end
	
	complete_game = false;
end

--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
function AddMiniGamesGUI_Race(screen)
	GUI_Z = 1000;
	
	SKIP_START_TIME = 0.4;
	
	--play_field:GetLevelScreen():GetPanel():Stop();
	--play_field:SetEnabled(false);
		
	minigames_gui = {};
	minigames_gui.screen = screen;
	minigames_gui.skip_flag = false;
	minigames_gui.anim_skip = nil;
	
	TimerDoString("minigames_gui.screen:Stop()", SKIP_START_TIME, minigames_gui.screen:GetTimer());
	TimerDoString("load_screen('data/Lua/Screens/DialogMiniGameHelp.lua')", SKIP_START_TIME, minigames_gui.screen:GetTimer());
	
	--менюшка
	local anim = CreateAnimation('data/Texture/GUI/MiniGames/win.png',0,0,166,197,1,0)
	minigames_gui.screen:CreateObject('win',anim,858,0,GUI_Z,0,1,1)
	--шкала
	local anim = CreateAnimation('data/Texture/GUI/MiniGames/st.png',0,0,69,69,1,0)
	minigames_gui.screen:CreateObject('st',anim,893,14,GUI_Z + 200,0,1,1)
	-------------------------------------------------------------------------------------------
	
	ShowGameHelpButton(minigames_gui.screen);
	ShowGameExitButton_07_Race(minigames_gui.screen);
end

function ShowGameHelpButton_07_Race(screen)
	--кнопка Help
	local up = CreateAnimation('data/Texture/GUI/MiniGames/help.png',  0,0, 77,47,1,0)
	local over = CreateAnimation('data/Texture/GUI/MiniGames/help.png',0,47,77,47,1,0)
	local down = CreateAnimation('data/Texture/GUI/MiniGames/help.png',0,94,77,47,1,0)
	minigames_gui.button_help = CreateButton(up, over, down, "MiniGameHelp", screen)
	minigames_gui.button_help:AttachTo(screen);
	minigames_gui.button_help:SetXY(941, 121);
	minigames_gui.button_help:SetZ(GUI_Z + 4);
end

function ShowGameExitButton_07_Race(screen)
	--кнопка Help
	local up = CreateAnimation('data/Texture/GUI/MiniGames/exit.png',  0,0, 67,46,1,0)
	local over = CreateAnimation('data/Texture/GUI/MiniGames/exit.png',0,46,67,46,1,0)
	local down = CreateAnimation('data/Texture/GUI/MiniGames/exit.png',0,92,67,46,1,0)
	minigames_gui.button_exit = CreateButton(up, over, down, "MiniGameExit", screen)
	minigames_gui.button_exit:AttachTo(screen);
	minigames_gui.button_exit:SetXY(892, 23);
	minigames_gui.button_exit:SetZ(GUI_Z + 4);
end

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

function InitPanel()
	local Panel = game_state.screen:GetObject('panel_mg');
	auxAttachInPlace(game_state.screen:GetObject('kon_a'), Panel);
	auxAttachInPlace(game_state.screen:GetObject('kon_b'), Panel);
	auxAttachInPlace(game_state.screen:GetObject('kon_c'), Panel);
	auxAttachInPlace(game_state.screen:GetObject('kon_d'), Panel);
	
	for i = 1, 4 do
		auxAttachInPlace(game_state.screen:GetObject('left_'..i), Panel);
		auxAttachInPlace(game_state.screen:GetObject('right_'..i), Panel);
		auxAttachInPlace(game_state.screen:GetObject('pixel_l_'..i), Panel);
		auxAttachInPlace(game_state.screen:GetObject('pixel_r_'..i), Panel);
	end
	
	auxAttachInPlace(game_state.screen:GetObject('ok_'), Panel);
	game_state.screen:GetObject('ok_'):GetAnimation():SetFrame(0);
end

--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
function InitFinishText()
	txt = CreateTextEntity('Bookman24Orange','');
    txt:AttachTo(game_state.screen);
	txt:SetZ(600.0);
	txt:SetTracking(-3.0);
	txt:SetScale(1.5);
end

function InitWinnerText()
	txt_w = CreateTextEntity('Bookman24Orange','');
    txt_w:AttachTo(game_state.screen);
	txt_w:SetZ(600.0);
	txt_w:SetTracking(-3.0);
	txt_w:SetScale(1.5);
end

function UpdateFinishText()
	if(game_state.game_over == false) then
		if(show_win_text == true) then
			txt:SetXY(512, 30);
			txt:SetText(GetString("MINI_GAME_AWARD_1").." "..money_win.." "..GetString("MINI_GAME_AWARD_2"));
			txt_w:SetXY(512, 230);
			txt_w:SetText(GetString("MINI_GAME_AWARD_4"))
		else
			txt:SetXY(512, 30);
			txt:SetText("");
			txt_w:SetXY(512, 30);
			txt_w:SetText("");
		end
	else
		txt:SetXY(512, 30);
		txt:SetText(GetString("MINI_GAME_AWARD_3"));
	end
end

function InitCashAmountText()
	info = CreateTextEntity('Main','');
    info:AttachTo(game_state.screen:GetObject('panel_mg'));
	info:SetZ(502.0);
	info:SetTracking(-8.0);
	info:SetScale(1.0);
end

function TextCashAmountUpdate()
	info:SetXY(0, -229);
	info:SetText(""..money_amount);
end

function InitStake1Text()
	text1 = CreateTextEntity('Main','');
    text1:AttachTo(game_state.screen:GetObject('panel_mg'));
	text1:SetZ(502.0);
	text1:SetTracking(-8.0);
	text1:SetScale(1.0);
end

function TextStake1Update()
	text1:SetXY(50, -108);
	text1:SetText(""..stake[1]);
end

function InitStake2Text()
	text2 = CreateTextEntity('Main','');
    text2:AttachTo(game_state.screen:GetObject('panel_mg'));
	text2:SetZ(502.0);
	text2:SetTracking(-8.0);
	text2:SetScale(1.0);
end

function TextStake2Update()
	text2:SetXY(50, -57);
	text2:SetText(""..stake[2]);
end

function InitStake3Text()
	text3 = CreateTextEntity('Main','');
    text3:AttachTo(game_state.screen:GetObject('panel_mg'));
	text3:SetZ(502.0);
	text3:SetTracking(-8.0);
	text3:SetScale(1.0);
end

function TextStake3Update()
	text3:SetXY(50, 3);
	text3:SetText(""..stake[3]);
end

function InitStake4Text()
	text4 = CreateTextEntity('Main','');
    text4:AttachTo(game_state.screen:GetObject('panel_mg'));
	text4:SetZ(502.0);
	text4:SetTracking(-8.0);
	text4:SetScale(1.0);
end

function TextStake4Update()
	text4:SetXY(50, 61);
	text4:SetText(""..stake[4]);
end
--------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------
function HideZagon()
	for i = 1, 5 do
		game_state.screen:GetObject(""..i):SetVisible(false);
	end
end

function Start()
	mini_game_finish = false;
	
	local time = 1.5;
	
	for i = 1, 4 do
		Objects[i].Entity:GetAnimation():Play();
		Objects[i].Entity:Move(400.0, 0.0, time);
	end
	
	PlayGallop();
	
	TimerDoString('HideZagon();', time / 2, game_state.screen:GetTimer());
	TimerDoString('Move();', time, game_state.screen:GetTimer());
	TimerDoString('Composition:Play();', time, game_state.screen:GetTimer());
	TimerDoString('PlayFlag();', time, game_state.screen:GetTimer());
	

	TimerDoString('Finish();', 15.08 + time, game_state.screen:GetTimer());
end

function PlayIntro()
	game_state.intro_sound = CreateSoundEntity('Award_intro');
	game_state.intro_sound:AttachTo(game_state.screen)
	game_state.intro_sound:Play(true)
end

function PlayFinalSound()
	game_state.final_sound = CreateSoundEntity('Award_final');
	game_state.final_sound:AttachTo(game_state.screen)
	game_state.final_sound:Play(false)
end

function PlayGallop()
	game_state.intro_sound:Stop();
	game_state.gallop_sound = CreateSoundEntity('Award_gallop');
	game_state.gallop_sound:AttachTo(game_state.screen)
	game_state.gallop_sound:Play(true)
end

function StopGallop()
	game_state.gallop_sound:Stop();
end

function Finish()

	for i = 1, 4 do
		Objects[i].Entity:Move(1100.0, 0.0, 2.4);
	end
	TimerDoString('StopGallop();', 1.4, game_state.screen:GetTimer());
	complete_game = true;
end


function OnSceneFree(screen)	
	game_state.gallop_sound:Stop();
	game_state.final_sound:Stop();
	game_state.intro_sound:Stop();
	
    FreeData(screen)
end

function OnScreenShown()
end
    
function SkipMiniGame()
	return 0.1;
end    

function OnUpdate(dt)
	TextCashAmountUpdate();
	TextStake1Update();
	TextStake2Update();
	TextStake3Update();
	TextStake4Update();
	UpdateFinishText();
	
	for i = 1, 4 do
		if(mini_game_finish == false and Objects[i].BreakFlag == false and Objects[i].Entity:GetX() >  FinishPos[Objects[i].Way]) then
			money_win = stake[Objects[i].Way] * 3;
			money_amount = money_amount + money_win;
			mini_game_finish = true;
			show_win_text = true;
			
			Objects[i].Entity:GetAnimation():SetFrame(8);
			Objects[i].Entity:GetAnimation():Stop();
			Objects[i].Entity:SetXY(530, 150)
			
			if(money_amount == 0) then
				game_state.game_over = true;
			end
			
			for j = 1, 4 do
				stake[j] = 0;
				StartFlag[j] = false;
			end
			
			if(game_state.game_over == false) then
				Objects[i].Winner:SetVisible(true);
				TimerDoString('PlayFinalSound()', 1.0, game_state.screen:GetTimer());
				TimerDoString('ReverseScreen()', 6.0, game_state.screen:GetTimer());
			else
				TimerDoString('ExitToMenu()', 2.0, game_state.screen:GetTimer());
			end
		end
	end
end

function ExitToMenu()
	game_state.screen:Stop();
	game_state.screen:SetOpacity(0);
	game_state.screen:ScreenDestroy();
	load_screen('data/Lua/Screens/Menu.lua');
end

function ReverseScreen()
	Flag:SetXY(-100, -100);
	for i = 1, 5 do
		game_state.screen:GetObject(""..i):SetVisible(true);
	end
	
	break_horse = false;
	show_win_text = false;
	Composition:Rewind(false);
	InitilizationGame();
	TimerDoString('PlayIntro()', 0.5, game_state.screen:GetTimer());
	game_state.screen:GetObject("panel_mg"):SetX(-138);
	game_state.screen:GetObject("panel_mg"):Move(250, 0, 1.0);
end

function Move()
	if(complete_game == false) then
		
		for i = 1, 4 do
			if(Objects[i].BreakFlag == false) then
				if(math.random(100) < 50 + ((i - 2) * 4)) then
					if(Objects[i].Entity:GetX() < 650) then
						Objects[i].Entity:Move(math.random(80), 0.0, 1.0);
					end
				else
					if(Objects[i].Entity:GetX() > 200) then
						Objects[i].Entity:Move(-math.random(80), 0.0, 1.0);
					end
				end
			end
		end
	
		TimerDoString('Move()', 1.0, game_state.screen:GetTimer());
		
		if(break_horse == false and math.random(1000) < 200) then
			break_horse = true;
			local index = math.random(4);
			Objects[index].Entity:SetVisible(false);
			Objects[index].EntityBreak:SetXY(Objects[index].Entity:GetX(), Objects[index].Entity:GetY());
			Objects[index].EntityBreak:SetVisible(true);
			Objects[index].EntityBreak:GetAnimation():Play();
			Objects[index].EntityBreak:Move(-1024, 0, 2.5);
			Objects[index].BreakFlag = true;
		end
	end
end

function OnLose()
end

function OnExit()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
    
    obj_name = object:GetName();
    
    game_state.screen:GetObject('ok_'):GetAnimation():SetFrame(0);
    for i = 1, 4 do
		game_state.screen:GetObject('left_'..i):GetAnimation():SetFrame(0);
		game_state.screen:GetObject('right_'..i):GetAnimation():SetFrame(0);
    end
		
    if(obj_name == 'ok_') then
		game_state.screen:GetObject('ok_'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_l_1') then
		game_state.screen:GetObject('left_1'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_l_2') then
		game_state.screen:GetObject('left_2'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_l_3') then
		game_state.screen:GetObject('left_3'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_l_4') then
		game_state.screen:GetObject('left_4'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_r_1') then
		game_state.screen:GetObject('right_1'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_r_2') then
		game_state.screen:GetObject('right_2'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_r_3') then
		game_state.screen:GetObject('right_3'):GetAnimation():SetFrame(1);
	elseif(obj_name == 'pixel_r_4') then
		game_state.screen:GetObject('right_4'):GetAnimation():SetFrame(1);
    end
end


function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

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

    --is_wrong_click = DefaultOnObjectMouseDown(object)

	if(obj_name == 'ok_') then
		game_state.screen:GetObject('panel_mg'):Move(-250, 0, 1.0);
		TimerDoString('Start();', 1.0, game_state.screen:GetTimer());
	else
		for i = 1, 4 do
			if(obj_name == "pixel_l_"..i) then
				SubStake(i);
			end
			if(obj_name == "pixel_r_"..i) then
				AddStake(i);
			end
		end
	end
	
    if is_wrong_click then
        --pf:ShowWrongObjectEffect()
    end    
end

function AddStake(index)
	if(money_amount > 0 and stake[index] < 100) then
		stake[index] = stake[index] + 10;
		money_amount = money_amount - 10;
	end
end

function SubStake(index)
	if(stake[index] > 0) then
		stake[index] = stake[index] - 10;
		money_amount = money_amount + 10;
	end
end

function OnObjectMouseUp(object)
end

function OnObjectWillBeFound(object)
end

function OnToolFound(tool)
end

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

function OnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
    
    if title == "MiniGameHelp" then  
		minigames_gui.screen:Stop();
		load_screen("data/Lua/Screens/DialogMiniGameHelp.lua")
    end
    if title == "MiniGameExit" then  
		game_state.screen:Stop();
		game_state.screen:SetOpacity(0);
		game_state.screen:ScreenDestroy();
		load_screen('data/Lua/Screens/Menu.lua');
    end
end

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function CanBeHinted(obj)
    if locked_object[obj] ~= true then
        return true
    else
        return false
    end
end

function OnLostFocus()
end

function OnGainFocus()
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/bl_run.png',0,0,290,135,16,25)
	anim:SetHotSpot(145,67)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('run_1',anim,151,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/gr_run.png',0,0,334,176,16,25)
	anim:SetHotSpot(167,88)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('run_2',anim,116,465,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/lil_run.png',0,0,295,136,16,25)
	anim:SetHotSpot(147,70)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('run_3',anim,108,555,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/or_run.png',0,0,239,130,16,25)
	anim:SetHotSpot(120,65)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('run_4',anim,74,668,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/bl_fall.png',0,0,288,189,30,30)
	anim:SetHotSpot(144,95)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fall_1',anim,762,79,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/gr_fall.png',0,0,313,179,31,25)
	anim:SetHotSpot(157,90)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fall_2',anim,755,180,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/lil_fall.png',0,0,275,151,31,25)
	anim:SetHotSpot(412,75)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fall_3',anim,1011,283,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/or_fall.png',0,0,238,140,31,25)
	anim:SetHotSpot(120,70)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fall_4',anim,753,379,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/Flag.png',0,0,239,584,1,0)
	anim:SetHotSpot(119,292)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Flag',anim,693,464,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/_start.png',0,0,512,768,1,0)
	anim:SetHotSpot(256,384)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('_start',anim,256,384,90,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/1.png',0,0,154,87,1,0)
	anim:SetHotSpot(77,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1',anim,77,682,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/2.png',0,0,172,150,1,0)
	anim:SetHotSpot(86,75)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2',anim,86,566,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/3.png',0,0,189,138,1,0)
	anim:SetHotSpot(94,69)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3',anim,97,477,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/4.png',0,0,163,124,1,0)
	anim:SetHotSpot(81,62)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4',anim,126,397,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/5.png',0,0,127,253,1,0)
	anim:SetHotSpot(63,126)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5',anim,63,416,120,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/kon_b.png',0,0,74,60,1,0)
	anim:SetHotSpot(37,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kon_b',anim,88,242,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/kon_a.png',0,0,74,60,1,0)
	anim:SetHotSpot(37,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kon_a',anim,88,177,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/kon_c.png',0,0,74,60,1,0)
	anim:SetHotSpot(37,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kon_c',anim,88,370,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/kon_d.png',0,0,74,60,1,0)
	anim:SetHotSpot(37,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kon_d',anim,87,304,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/ok_.png',0,0,58,60,2,0)
	anim:SetHotSpot(29,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('ok_',anim,42,518,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/left.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('left_1',anim,124,191,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/left.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('left_2',anim,124,241,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/left.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('left_3',anim,125,302,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/left.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('left_4',anim,125,361,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/righ.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('right_1',anim,202,190,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/righ.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('right_2',anim,202,241,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/righ.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('right_3',anim,202,301,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/righ.png',0,0,20,24,2,0)
	anim:SetHotSpot(10,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('right_4',anim,203,359,501,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_l_1',anim,123,190,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_r_1',anim,201,192,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_l_2',anim,126,242,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_r_2',anim,203,242,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_l_3',anim,126,301,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_r_3',anim,204,302,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_l_4',anim,125,360,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel_r_4',anim,202,360,503,0,3,3)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/Win_Lilas.png',0,0,435,415,1,0)
	anim:SetHotSpot(218,208)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('winer_3',anim,510,140,100,0,0.4,0.4)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/Win_Green.png',0,0,435,415,1,0)
	anim:SetHotSpot(218,208)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('winer_2',anim,510,140,100,0,0.4,0.4)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/Win_Orang.png',0,0,435,415,1,0)
	anim:SetHotSpot(218,208)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('winer_4',anim,510,140,100,0,0.4,0.4)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/Win_Blu.png',0,0,435,415,1,0)
	anim:SetHotSpot(218,208)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('winer_1',anim,510,140,100,0,0.4,0.4)
	local anim = CreateAnimation('data/Texture/Minigames/Award_Race/panel/panel_mg.png',0,0,247,614,1,0)
	anim:SetHotSpot(123,307)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('panel_mg',anim,116,296,500,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
