function CreateCard(count)
    local card = {};
    
    card.obj   = play_field:GetObject('Card');
    card.nodes = {};
    card.count = count;
    
    for i=1, card.count do
        card.nodes[i] = {}
        
        card.nodes[i] = play_field:GetObject('card'..i);
        card.nodes[i]:AttachTo(card.obj);
        card.nodes[i]:SetZ(1);
        card.nodes[i]:SetX( card.nodes[i]:GetX() - card.obj:GetX() );
        card.nodes[i]:SetY( card.nodes[i]:GetY() - card.obj:GetY() );
    end
    
    card.close = function ()
        card.obj:SetXY(496, 330);
    end
    
    card.open = function (time)
        if time == 0
        then
            card.obj:SetXY(309, 369);
        else
            if card.openEffector == nil then
                card.openEffector = CreateAnimationEffector();
                card.openEffector:AttachTo(card.obj);
                card.openEffector:SetMode(HGEANIM_FWD + HGEANIM_NOLOOP);
                card.openEffector:SetKey(_TRACK_X,    0, 496);
                card.openEffector:SetKey(_TRACK_X, time, 309);
                
                card.openEffector:SetKey(_TRACK_Y,    0, 330);
                card.openEffector:SetKey(_TRACK_Y, time, 369);
            end
            
            card.openEffector:Play();
        end
    end
    
    card.reset = function()
        for i=1, card.count do
            card.nodes[i]:SetVisible(true);
        end
    end
    
    card.setVisible = function(visible)
        card.obj:SetVisible(visible);
    end
    
    card.isVisible = function()
        return card.obj:IsVisible();
    end
    
    return card;
end

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

function MG_OnSceneLoad(screen)
    game_state.card = CreateCard(24)
	game_state.card.setVisible(false);
	game_state.card.close();
    game_state.card.reset();
	
	game_state.pressDepth = 3;
	game_state.mg_enable  = false;
	
	MG_LoadPunchcardButtonsState();
	
	MG_CreateZoomZone();
	
	LoadSound('28_Push_lever', 'data/Sound/28_Master_Room/Perforator/Push_lever.ogg')
	LoadSound('28_Push_numbers', 'data/Sound/28_Master_Room/Perforator/Push_numbers.ogg')
	LoadSound('28_Put_numbers', 'data/Sound/28_Master_Room/Perforator/Put_numbers.ogg')
	LoadSound('28_Put_card', 'data/Sound/28_Master_Room/Perforator/Put_card.ogg')
end

function MG_CreateZoomZone()

    punchcard_zone = CreateZoomZone('Layer_Perforator',
                                    'CloseZonePunchcard',
                                    'MG_fon',            true,
                                    'Layer_card_over',   true,
                                    'Layer_left',        true,
                                    'Card',              true,
                                    'Layer_Bottom',      true,
                                    
                                    'mg_btn1',           true,
                                    'mg_btn2',           false,
                                    'mg_btn3',           true,
                                    'mg_btn4',           true,
                                    'mg_btn5',           true,
                                    'mg_btn6',           true,
                                    'mg_btn7',           true,
                                    'mg_btn8',           true,
                                    'mg_btn9',           true,
                                    'mg_btn10',          true,
                                    'mg_btn11',          false,
                                    'mg_btn12',          true,
                                    'mg_btn13',          true,
                                    'mg_btn14',          true,
                                    'mg_btn15',          true,
                                    'mg_btn16',          true,
                                    'mg_btn17',          true,
                                    'mg_btn18',          true,
                                    'mg_btn19',          true,
                                    'mg_btn20',          true,
                                    'mg_btn21',          true,
                                    'mg_btn22',          true,
                                    'mg_btn23',          true,
                                    'mg_btn24',          true,
                                    
                                    'card1',             true,
                                    'card2',             true,
                                    'card3',             true,
                                    'card4',             true,
                                    'card5',             true,
                                    'card6',             true,
                                    'card7',             true,
                                    'card8',             true,
                                    'card9',             true,
                                    'card10',            true,
                                    'card11',            true,
                                    'card12',            true,
                                    'card13',            true,
                                    'card14',            true,
                                    'card15',            true,
                                    'card16',            true,
                                    'card17',            true,
                                    'card18',            true,
                                    'card19',            true,
                                    'card20',            true,
                                    'card21',            true,
                                    'card22',            true,
                                    'card23',            true,
                                    'card24',            true,
                                    'Layer_Punchcards',  false,
                                    'Layer_Punchcards_Over', true,
                                    'area_tool_apply',       true,
                                    'area_cards_placed',     false,
                                    'area_get_correct_punchcard',     false,
                                    'area_get_not_correct_punchcard', false,
                                    'area_lever',        false,
                                    'Punchcard_in_hand', false,
                                    'area_punchcard_devices', false,
                                    'area_punchcard_devices_hints', false,
                                    'Layer_Lever_1',     true,
                                    'Layer_Lever_2',     false,
                                    'Layer_btn_empty',   true,
                                    'Layer_Punchcard_in', false,
									'Layer_Box_Light', false
                              );
	
	play_field:GetObject('area_tool_apply'               ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_lever'                    ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_cards_placed'             ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_punchcard_devices'        ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_punchcard_devices_hints'  ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_get_correct_punchcard'    ):GetAnimation():SetColor('0x01FFFFFF');
	play_field:GetObject('area_get_not_correct_punchcard'):GetAnimation():SetColor('0x01FFFFFF');
	
	play_field:GetObject('Punchcard_in_hand'):SetClippingRect(512 - 320, 384 - 240, 640, 480);
	play_field:IgnoreOnTestPoint('Punchcard_in_hand');
    
    
    punchcard_zone.on_open = function()
    
        local restart = HasGameState('RestartMiniGame', '29_perforator');
        
        local on_load_26_button_applied = function()
        
            punchcard_zone.SetObjectVisible('mg_btn11', true);
            punchcard_zone.SetObjectVisible('Layer_btn_empty', false);
            game_state.button_26_applied = true;
            
            zone_table.SetObjectVisible('no_button_11', false);
            
            MG_CheckAllToolsApplied();
        
        end
        
        local on_26_button_apply = function()
            on_load_26_button_applied()
            MakeSoundEntity('28_Put_numbers'):Play(false);
        end
        
        local on_load_28_button_applied = function()
            punchcard_zone.SetObjectVisible('mg_btn2', true);
            game_state.button_28_applied = true;
            
            zone_table.SetObjectVisible('no_button_2', false);
            
            MG_CheckAllToolsApplied();
        end
        
        local on_28_button_apply = function()
            on_load_28_button_applied()
            MakeSoundEntity('28_Put_numbers'):Play(false);
        end
        
        local on_29_punchcards_apply = function()
            punchcard_zone.SetObjectVisible('Layer_Punchcards', true);
            game_state.punchcards_applied = true;
            
            MG_CheckAllToolsApplied();
        end
        
        local on_punchcards_click = function()
            game_state.punchcard_in_hand = not game_state.punchcard_in_hand;
            
            if game_state.punchcard_in_hand then
                local mouse_pos = GetMousePos();
                play_field:GetObject('Punchcard_in_hand'):SetXY(mouse_pos.x, mouse_pos.y);
            end
            
            punchcard_zone.SetObjectVisible('Punchcard_in_hand',      game_state.punchcard_in_hand);
            punchcard_zone.SetObjectVisible('area_punchcard_devices', game_state.punchcard_in_hand);
            punchcard_zone.SetObjectVisible('area_punchcard_devices_hints', not game_state.punchcard_in_hand);
        end
        
        
        local on_punchcards_use = function()
            game_state.punchcard_in_hand = false;
            punchcard_zone.SetObjectVisible('area_lever',             true);
            punchcard_zone.SetObjectVisible('area_punchcard_devices', false);
            punchcard_zone.SetObjectVisible('area_cards_placed',      false);
            punchcard_zone.SetObjectVisible('Punchcard_in_hand',      false);
            punchcard_zone.SetObjectVisible('Layer_Punchcard_in',     true);
            
			punchcard_zone.SetObjectVisible('Layer_Box_Light', false)
            game_state.custom_cursors['area_punchcard_devices_hints'] = nil
            
            PlayPutPunchcardSound();
            
            game_state.card.setVisible(true);
            MG_SetEnable(true)
        end
        
        local on_load_when_punchcards_used = function()
            punchcard_zone.SetObjectVisible('area_lever', true);
            punchcard_zone.SetObjectVisible('area_cards_placed', false);
            punchcard_zone.SetObjectVisible('area_punchcard_devices', false);
            punchcard_zone.SetObjectVisible('area_punchcard_devices_hints', false);
            punchcard_zone.SetObjectVisible('Layer_Punchcard_in', true);
            
            punchcard_zone.SetObjectVisible('Layer_Box_Light', false)
            game_state.custom_cursors['area_punchcard_devices_hints'] = nil
            
            game_state.card.setVisible(true);
            MG_SetEnable(true)
        end
        
        
        local on_lever_use = function()
            punchcard_zone.SetObjectVisible('area_lever', false);
            
            local eff1 = CreateAnimationEffector();
            eff1:AttachTo( play_field:GetObject('Layer_Lever_1') );
            eff1:SetMode(_ANIM_FWD + _ANIM_NOLOOP);
            
            local eff2 = CreateAnimationEffector();
            eff2:AttachTo( play_field:GetObject('Layer_Lever_2') );
            eff2:SetMode(_ANIM_FWD + _ANIM_NOLOOP);
            
            eff1:SetKey(_TRACK_O, 0,   1);
            eff1:SetKey(_TRACK_O, 0.3, 0);
            eff1:SetKey(_TRACK_O, 0.6, 1);
            eff1:Play();
            
            eff2:SetKey(_TRACK_O, 0,   0);
            eff2:SetKey(_TRACK_O, 0.3, 1);
            eff2:SetKey(_TRACK_O, 0.6, 0);
            eff2:Play();
            
            if MG_IsCurrentCombinationCorrect() then
                punchcard_zone.SetObjectVisible('area_get_correct_punchcard', true);
            else
                punchcard_zone.SetObjectVisible('area_get_not_correct_punchcard', true);
            end
            
            TimerDoString('MG_ShowCard()', 0.6, play_field:GetTimer())
            --game_state.card.open(1);
            MG_SetEnable(false);
            
            MakeSoundEntity("28_Push_lever"):Play(false);
        end
        
        local on_load_when_lever_used = function()
            punchcard_zone.SetObjectVisible('area_lever', false);
            punchcard_zone.SetObjectVisible('Layer_Punchcard_in', false);
            
            if MG_IsCurrentCombinationCorrect() then
                punchcard_zone.SetObjectVisible('area_get_correct_punchcard', true);
            else
                punchcard_zone.SetObjectVisible('area_get_not_correct_punchcard', true);
            end
            
            game_state.card.open(0);
            MG_SetEnable(false);
        end
        
        local on_correct_punchcard_found = function()
            game_state.card.setVisible(false);
            punchcard_zone.Disable();
			game_state.ignore_on_highlight['area_table'] = true
			punchcard_zone.SetObjectVisible('Layer_Box_Light', true)
        end
        
        local on_load_correct_punchcard_found = function()
            game_state.card.setVisible(false);
			game_state.ignore_on_highlight['area_table'] = true
			punchcard_zone.SetObjectVisible('Layer_Box_Light', true)
        end

        local on_wrong_punchcard_found = function()
            game_state.card.setVisible(false);
            punchcard_zone.Disable();
			punchcard_zone.SetObjectVisible('Layer_Box_Light', true)
        end
        
        local on_load_wrong_punchcard_found = function()
            game_state.card.setVisible(false);
			punchcard_zone.SetObjectVisible('Layer_Box_Light', true)
        end
        
        RegisterToolApplyInfo('28_button',     'area_tool_apply', nil, nil, on_28_button_apply,     on_load_28_button_applied);
        RegisterToolApplyInfo('26_button',     'area_tool_apply', nil, nil, on_26_button_apply,     on_load_26_button_applied);
        RegisterToolApplyInfo('29_punchcards', 'area_tool_apply', nil, nil, on_29_punchcards_apply, on_29_punchcards_apply);
        
        RegisterActiveObject('area_cards_placed',      on_punchcards_click, nil, true);
        RegisterActiveObject('area_punchcard_devices', on_punchcards_use,   on_load_when_punchcards_used);
        RegisterActiveObject('area_lever',             on_lever_use,        on_load_when_lever_used, true);
        
        RegisterToolFindInfo('29_punchcard_done', 'area_get_correct_punchcard', on_correct_punchcard_found, on_load_correct_punchcard_found);
        RegisterToolFindInfo('29_punchcard_wrong', 'area_get_not_correct_punchcard', on_wrong_punchcard_found,   on_load_wrong_punchcard_found);
        
    end

end

--------------------------------------------------------------------------------
function PlayPutPunchcardSound()
    if not play_field.putPunchcardSound
    then
        play_field.putPunchcardSound = MakeSoundEntity('28_Put_card');
    end
    
    play_field.putPunchcardSound:StopSound();
    play_field.putPunchcardSound:Play(false);
end

--------------------------------------------------------------------------------
function MG_OnTableZoneOpen()

    local wasDisabled = punchcard_zone.IsDisabled();
    local restart = HasGameState('RestartMiniGame', '29_perforator');
    if restart
    then
        MG_Restart();
        return;
    end
    
    if not HasGameState('ToolFound', '29_punchcard_done') and
       not HasGameState('ToolFound', '29_punchcard_wrong') and
       punchcard_zone ~= nil
    then
        punchcard_zone.Enable();
    else
        punchcard_zone.Disable();
    end
    
end

--------------------------------------------------------------------------------
function MG_ShowCard()
    punchcard_zone.SetObjectVisible('Layer_Punchcard_in', false);
    game_state.card.open(1);
end

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

function MG_IsToolsApplied()
    return game_state.punchcards_applied and
           game_state.button_26_applied  and
           game_state.button_28_applied;
end

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

function MG_CheckAllToolsApplied()
	punchcard_zone.SetObjectVisible('Layer_Box_Light',
									game_state.button_26_applied and
									game_state.button_28_applied and
									not game_state.mg_enable)

    if MG_IsToolsApplied() then
        punchcard_zone.SetObjectVisible('area_tool_apply', false);
        punchcard_zone.SetObjectVisible('area_cards_placed', true);
        punchcard_zone.SetObjectVisible('area_punchcard_devices_hints', true);
        
        game_state.custom_cursors['area_punchcard_devices_hints'] = 'CursorGlass'
    else
        game_state.custom_cursors['area_tool_apply'] = 'CursorGlass'
    end
end

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

function MG_IsCurrentCombinationCorrect()
    local correct    = {2,6,11,15,18};
    local find_count = 0;
    local btn_name;
    local find;
    
    for i=1, 24 do
        btn_name = 'mg_btn'..i;
        
        if HasGameState('PunchcardBtnPress', btn_name) then
            find = false;
            
            for index, value in ipairs(correct) do
                if value == i then
                    find = true;
                    find_count = find_count + 1;
                    break;
                end
            end
            
            if not find then
                return false;
            end
        end
    end
    
    return find_count == table.getn(correct);
end

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

function MG_SetEnable(enable)
    if enable == game_state.mg_enable then
        return;
    end
    
    game_state.mg_enable = enable;
    
    if enable then
        for i=1, 24 do
            game_state.custom_cursors['mg_btn'..i] = 'CursorActive'
        end
    else
        for i=1, 24 do
            game_state.custom_cursors['mg_btn'..i] = nil;
        end
    end
end

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

function MG_LoadPunchcardButtonsState()
    local btn;
    local btn_name;
    
    for i=1, 24 do
        btn_name = 'mg_btn'..i;
        btn      = play_field:GetObject(btn_name);
        
        if HasGameState('PunchcardBtnPress', btn_name)
        then
            play_field:GetObject('card'..i):SetVisible(false);
            btn:SetY( btn:GetY() + game_state.pressDepth );
            btn:GetAnimation():SetColor('0xFF999999');
        else
            btn:GetAnimation():SetColor('0xFFFFFFFF');
        end
    end
end

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

function MG_OnPunchcardButtonPress(obj_name)
    local num  = string.sub(obj_name, 7, string.len(obj_name));
    local obj  = play_field:GetObject(obj_name);
    local node = play_field:GetObject('card'..num);
    
    if HasGameState('PunchcardBtnPress', obj_name)
    then
        RemoveGameState('PunchcardBtnPress', obj_name);
        node:SetVisible(true);
        obj:SetY( obj:GetY() - game_state.pressDepth );
        obj:GetAnimation():SetColor('0xFFFFFFFF');
    else
        AddGameState('PunchcardBtnPress', obj_name);
        node:SetVisible(false);
        obj:SetY( obj:GetY() + game_state.pressDepth );
        obj:GetAnimation():SetColor('0xFF999999');
    end
    
    if not play_field.perforatorButtonSound
    then
        play_field.perforatorButtonSound = MakeSoundEntity('28_Push_numbers');
        play_field.perforatorButtonSound:Play(false);
    else
        play_field.perforatorButtonSound:StopSound();
        play_field.perforatorButtonSound:Play(false);
    end
    
end

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

function MG_OnObjectMouseDown(object)
    local obj_name = object:GetName()
    
    if game_state.mg_enable and string.sub(obj_name, 1, 6) == 'mg_btn'
    then
        MG_OnPunchcardButtonPress(obj_name);
    end
    
    if obj_name == 'area_tool_apply'
    then
        local twoButtonsMissing = not game_state.button_26_applied and not game_state.button_28_applied;
        local oneButtonMissing = not game_state.button_26_applied or not game_state.button_28_applied;
        if twoButtonsMissing
        then
            ShowMonolog('C_28_PUNCHCARDS_NO_BUTTONS', 'C_28_PUNCHCARDS_NO_BUTTONS');
        elseif oneButtonMissing
        then
            ShowMonolog('C_28_PUNCHCARDS_NO_BUTTON', 'C_28_PUNCHCARDS_NO_BUTTON');
        else
            ShowMonolog('C_28_PUNCHCARDS_HINT_2', 'C_28_PUNCHCARDS_HINT_2');
        end
    end
    
    if obj_name == 'area_punchcard_devices_hints' then
        ShowMonolog('C_28_PUNCHCARDS_HINT_3', 'C_28_PUNCHCARDS_HINT_3');
    end
end

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

function MG_OnUpdate(dt)
    if game_state.punchcard_in_hand
    then
        local mouse_pos = GetMousePos();
        play_field:GetObject('Punchcard_in_hand'):SetXY(mouse_pos.x, mouse_pos.y);
    end
end

--------------------------------------------------------------------------------
function MG_Restart()

    if HasGameState("ObjectClicked", "data/Scenes/28_Master_Room_Main.lua(area_punchcard_devices)")
    then
        RemoveGameState("ObjectClicked", "data/Scenes/28_Master_Room_Main.lua(area_punchcard_devices)");
    end
    if HasGameState("ObjectClicked", "data/Scenes/28_Master_Room_Main.lua(area_lever)")
    then
        RemoveGameState("ObjectClicked", "data/Scenes/28_Master_Room_Main.lua(area_lever)");
    end
    
    if HasGameState('ToolInfoShown', '29_punchcard_wrong')
    then
	    RemoveGameState('ToolInfoShown', '29_punchcard_wrong')
    end
    
    UnregisterZoomZone(punchcard_zone);
    play_field:DoNotIgnoreOnTestPoint(punchcard_zone.trigger_name);
    game_state.locked_objects[punchcard_zone.trigger_name] = false;
    
    MG_DestroyResources();
    
    dofile('data/Scenes/28_Master_Room_Main_Zoom_Table_Perforator.lua');
    LoadData(play_field);
    
    punchcard_zone = nil;
    
    game_state.card = CreateCard(24)
    game_state.card.setVisible(false);
    game_state.card.close();
    game_state.card.reset();
    
    MG_CreateZoomZone();
    
    RemoveGameState('RestartMiniGame', '29_perforator');
    game_state.locked_objects['area_punchcard_devices'] = nil;
    
    --MG_LoadPunchcardButtonsState();
    MG_ResetButtons();

end

--------------------------------------------------------------------------------
function MG_ResetButtons()

    for i=1, 24 do
        local btn_name = 'mg_btn'..i;
        
        if HasGameState('PunchcardBtnPress', btn_name)
        then
            RemoveGameState('PunchcardBtnPress', btn_name);
        end
    end

end

--------------------------------------------------------------------------------
function MG_DestroyResources()

    play_field:DeleteObject('MG_fon');
    play_field:DeleteObject('Layer_card_over');
    play_field:DeleteObject('Layer_left');
    play_field:DeleteObject('Card');
    play_field:DeleteObject('Layer_Bottom');
    
    play_field:DeleteObject('mg_btn1');
    play_field:DeleteObject('mg_btn2');
    play_field:DeleteObject('mg_btn3');
    play_field:DeleteObject('mg_btn4');
    play_field:DeleteObject('mg_btn5');
    play_field:DeleteObject('mg_btn6');
    play_field:DeleteObject('mg_btn7');
    play_field:DeleteObject('mg_btn8');
    play_field:DeleteObject('mg_btn9');
    play_field:DeleteObject('mg_btn10');
    play_field:DeleteObject('mg_btn11');
    play_field:DeleteObject('mg_btn12');
    play_field:DeleteObject('mg_btn13');
    play_field:DeleteObject('mg_btn14');
    play_field:DeleteObject('mg_btn15');
    play_field:DeleteObject('mg_btn16');
    play_field:DeleteObject('mg_btn17');
    play_field:DeleteObject('mg_btn18');
    play_field:DeleteObject('mg_btn19');
    play_field:DeleteObject('mg_btn20');
    play_field:DeleteObject('mg_btn21');
    play_field:DeleteObject('mg_btn22');
    play_field:DeleteObject('mg_btn23');
    play_field:DeleteObject('mg_btn24');
    
    play_field:DeleteObject('card1');
    play_field:DeleteObject('card2');
    play_field:DeleteObject('card3');
    play_field:DeleteObject('card4');
    play_field:DeleteObject('card5');
    play_field:DeleteObject('card6');
    play_field:DeleteObject('card7');
    play_field:DeleteObject('card8');
    play_field:DeleteObject('card9');
    play_field:DeleteObject('card10');
    play_field:DeleteObject('card11');
    play_field:DeleteObject('card12');
    play_field:DeleteObject('card13');
    play_field:DeleteObject('card14');
    play_field:DeleteObject('card15');
    play_field:DeleteObject('card16');
    play_field:DeleteObject('card17');
    play_field:DeleteObject('card18');
    play_field:DeleteObject('card19');
    play_field:DeleteObject('card20');
    play_field:DeleteObject('card21');
    play_field:DeleteObject('card22');
    play_field:DeleteObject('card23');
    play_field:DeleteObject('card24');
    play_field:DeleteObject('Layer_Punchcards');
    play_field:DeleteObject('Layer_Punchcards_Over');
    play_field:DeleteObject('area_tool_apply');
    play_field:DeleteObject('area_cards_placed');
    play_field:DeleteObject('area_get_correct_punchcard');
    play_field:DeleteObject('area_get_not_correct_punchcard');
    play_field:DeleteObject('area_lever');
    play_field:DeleteObject('Punchcard_in_hand');
    play_field:DeleteObject('area_punchcard_devices');
    play_field:DeleteObject('area_punchcard_devices_hints');
    play_field:DeleteObject('Layer_Lever_1');
    play_field:DeleteObject('Layer_Lever_2');
    play_field:DeleteObject('Layer_btn_empty');
    play_field:DeleteObject('Layer_Punchcard_in');

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/Punchcard/MG_fon.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('MG_fon',anim,512,384,159,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Card.png',0,0,219,136,1,0)
	anim:SetHotSpot(109,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Card',anim,309,369,161,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card1.png',0,0,21,18,1,0)
	anim:SetHotSpot(10,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card1',anim,235,355,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card2.png',0,0,22,20,1,0)
	anim:SetHotSpot(11,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card2',anim,237,371,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card3.png',0,0,18,17,1,0)
	anim:SetHotSpot(9,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card3',anim,239,388,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card4.png',0,0,21,16,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card4',anim,242,406,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card5.png',0,0,21,18,1,0)
	anim:SetHotSpot(10,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card5',anim,261,349,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card6.png',0,0,21,17,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card6',anim,265,365,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card7.png',0,0,21,17,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card7',anim,267,382,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card8.png',0,0,19,17,1,0)
	anim:SetHotSpot(9,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card8',anim,270,400,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card9.png',0,0,20,15,1,0)
	anim:SetHotSpot(10,7)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card9',anim,291,343,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card10.png',0,0,22,16,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card10',anim,295,360,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card11.png',0,0,21,16,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card11',anim,298,377,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card12.png',0,0,19,16,1,0)
	anim:SetHotSpot(9,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card12',anim,302,393,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card13.png',0,0,18,16,1,0)
	anim:SetHotSpot(9,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card13',anim,319,338,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card14.png',0,0,23,17,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card14',anim,322,354,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card15.png',0,0,20,16,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card15',anim,327,371,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card16.png',0,0,20,16,1,0)
	anim:SetHotSpot(10,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card16',anim,331,387,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card17.png',0,0,22,16,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card17',anim,346,333,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card18.png',0,0,22,17,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card18',anim,351,348,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card19.png',0,0,23,17,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card19',anim,354,364,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card20.png',0,0,23,20,1,0)
	anim:SetHotSpot(11,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card20',anim,359,382,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card21.png',0,0,23,19,1,0)
	anim:SetHotSpot(11,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card21',anim,371,327,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card22.png',0,0,22,19,1,0)
	anim:SetHotSpot(11,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card22',anim,378,343,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card23.png',0,0,23,19,1,0)
	anim:SetHotSpot(11,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card23',anim,382,359,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/card/card24.png',0,0,23,17,1,0)
	anim:SetHotSpot(11,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('card24',anim,388,375,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Bottom.PNG',0,0,195,78,1,0)
	anim:SetHotSpot(97,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Bottom',anim,596,375,170,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_card_over.PNG',0,0,136,136,1,0)
	anim:SetHotSpot(68,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_card_over',anim,445,337,175,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_left.PNG',0,0,101,179,1,0)
	anim:SetHotSpot(50,89)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_left',anim,467,308,170,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn24.png',0,0,64,42,1,0)
	anim:SetHotSpot(32,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn24',anim,653,329,197,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn23.png',0,0,62,44,1,0)
	anim:SetHotSpot(31,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn23',anim,612,338,198,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn22.png',0,0,61,44,1,0)
	anim:SetHotSpot(30,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn22',anim,569,347,199,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn21.png',0,0,61,43,1,0)
	anim:SetHotSpot(30,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn21',anim,526,355,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn20.png',0,0,59,52,1,0)
	anim:SetHotSpot(29,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn20',anim,631,308,193,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn19.png',0,0,59,52,1,0)
	anim:SetHotSpot(29,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn19',anim,592,316,194,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn18.png',0,0,58,52,1,0)
	anim:SetHotSpot(29,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn18',anim,551,324,195,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn17.png',0,0,58,50,1,0)
	anim:SetHotSpot(29,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn17',anim,510,331,196,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn16.png',0,0,57,53,1,0)
	anim:SetHotSpot(28,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn16',anim,611,284,189,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn15.png',0,0,56,50,1,0)
	anim:SetHotSpot(28,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn15',anim,573,291,190,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn14.png',0,0,56,52,1,0)
	anim:SetHotSpot(28,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn14',anim,534,298,191,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn13.png',0,0,56,53,1,0)
	anim:SetHotSpot(28,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn13',anim,495,305,192,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn12.png',0,0,53,51,1,0)
	anim:SetHotSpot(26,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn12',anim,593,260,185,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn11.png',0,0,53,53,1,0)
	anim:SetHotSpot(26,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn11',anim,556,269,186,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn10.png',0,0,53,52,1,0)
	anim:SetHotSpot(26,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn10',anim,518,274,187,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn9.png',0,0,52,52,1,0)
	anim:SetHotSpot(26,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn9',anim,480,281,188,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn8.png',0,0,51,46,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn8',anim,577,238,181,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn7.png',0,0,51,47,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn7',anim,541,243,182,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn6.png',0,0,51,46,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn6',anim,505,250,183,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn5.png',0,0,51,45,1,0)
	anim:SetHotSpot(25,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn5',anim,467,255,184,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn4.png',0,0,51,46,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn4',anim,561,216,177,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn3.png',0,0,49,42,1,0)
	anim:SetHotSpot(24,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn3',anim,526,222,178,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn2.png',0,0,49,44,1,0)
	anim:SetHotSpot(24,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn2',anim,490,228,179,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/buttons/mg_btn1.png',0,0,48,41,1,0)
	anim:SetHotSpot(24,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mg_btn1',anim,454,233,180,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Punchcards.png',0,0,246,143,1,0)
	anim:SetHotSpot(123,71)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Punchcards',anim,279,222,161,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Punchcards_Over.png',0,0,98,100,1,0)
	anim:SetHotSpot(49,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Punchcards_Over',anim,389,228,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,2)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_tool_apply',anim,547,274,202,0,60,53)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_cards_placed',anim,292,210,171,0,25,15)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Punchcard_to_Take.png',0,0,235,159,1,0)
	anim:SetHotSpot(117,79)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Punchcard_in_hand',anim,636,494,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_punchcard_devices',anim,538,367,202,0,50,50)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_punchcard_devices_hints',anim,538,367,201,0,50,50)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Lever_1.png',0,0,62,145,1,0)
	anim:SetHotSpot(31,72)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Lever_1',anim,732,221,161,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Lever_2.png',0,0,92,114,1,0)
	anim:SetHotSpot(46,57)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Lever_2',anim,693,232,162,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(2,2)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_lever',anim,735,202,163,0,10,17)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_get_correct_punchcard',anim,300,369,164,0,25,15)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_get_not_correct_punchcard',anim,300,369,164,0,25,15)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_btn_empty.png',0,0,72,36,1,0)
	anim:SetHotSpot(36,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_btn_empty',anim,555,259,186,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Punchcard_in.png',0,0,67,113,1,0)
	anim:SetHotSpot(33,56)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Punchcard_in',anim,402,352,163,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/Punchcard/Layer_Box_Light.PNG',0,0,295,390,1,0)
	anim:SetHotSpot(147,195)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Box_Light',anim,332,392,160,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
