GameScreen.textures_path = "graphics/screens/15_sport/location/"

function GameScreen:RestoreScreen()
    ------------------------------------------------------------------------------------------------------------------------------ 
    --Первая загрузка екрана
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "") then
        --стартовый диалог
        clScreenManager:add_screen("hud")   
        ItemSetOpacity(HUDScreen.name, 0.0)
    
        --local tip_end = function()
            
            ItemChangeOpacity(HUDScreen.name, 1.0, 0.5)
            DelayedExec(1.0, function()
                SetState(CURRENT_SCREEN, "ho", "active")
                self:StartHO();
            end, 113)
        --end
        --HUDScreen:ShowTips({path = self.textures_path.."Text_24", x = 567, y = 1128, end_fun = tip_end})
    end
    ------------------------------------------------------------------------------------------------------------------------------ 
    --ХО
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "active") then
        self:StartHO();
    end
    ------------------------------------------------------------------------------------------------------------------------------ 
    --после ХО
    ------------------------------------------------------------------------------------------------------------------------------ 
    if(GetState(CURRENT_SCREEN, "ho") == "completed") then
        clApplication:LoadLocation("016_tunnel")
    end
  
    for found_item in string.gmatch(GetState(CURRENT_SCREEN, "found_obj"), "[_%a%d]+") do
		ItemRemove(self.name, found_item)
		ItemRemove(self.name, found_item.."_shadow")
    end 
end

function GameScreen:InitScreen()
    self:LoadScreen()
   
    ------------------------------------------------------------------------------------------------------------------------------ 
    --OTHER       
    self:SetItemSound("cap", "sound/perfume_28.ogg");
    self:SetItemSound("glass", "sound/bottle_07.ogg");
    self:SetItemSound("spoon", "sound/metalware_04.ogg");
    self:SetItemSound("thimble", "sound/green_pot.ogg");
                
    MusicPlay({"sound/ambient/20_ambient.ogg", "sound/ambient/32_ambient.ogg"} , 15.1) 
    
    --self:AddHiddenCrystal("crystal_24_part")
    
    
    self:RestoreScreen()
end

function GameScreen:StartHO()    
    self.item_list = {
        {obj = {"dumbbell", {x = 992, y = 328}}},
        {obj = {"vaulting_buck", {x = 818, y = 733}}},
        {obj = {"trophy", {x = 956, y = 921}}, },
        {obj = {"punchbag", {x = 1457, y = 562}}, },
        {obj = {"bat15", {x = 1033, y = 716}}, },
        {obj = {"grip", {x = 503, y = 1007}}, },
        {obj = {"racket", {x = 26, y = 102}}, },
        {obj = {"rugby", {x = 783, y = 182}}, },
        {obj = {"whistle", {x = 448, y = 443}}, },
        {obj = {"shuttlecock", {x = 0, y = 510}}, },
        {obj = {"weight15", {x = 616, y = 343}}, },
        {obj = {"pin", {x = 458, y = 764}}, },
     }
     
    
    local on_finish = function()
        HUDScreen:SetInvntoryOnlyMode()
        SetState(CURRENT_SCREEN, "ho", "completed");
        self.mini_game = nil;
        --local tip_end = function()
            DelayedExec(1.0, function()
                clApplication:LoadLocation("016_tunnel")
            end, 113)
        --end
        --DelayedExec(1.0, function()
        --    HUDScreen:ShowTips({path = self.textures_path.."Text_24a", x = 320, y = 1113, end_fun = tip_end})
        --end, 113)
    end
       
    clScreenManager:add_screen("hud")                  
    self:SetMiniGame(mgt_hidden_object)
    self.mini_game.list_type = 2;   
    self.mini_game:Init(self.item_list, on_finish);
end

------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "15_sport", "graphics/screens/15_sport/location/15_sport", 0, 0);

    self:CreateObj(OBJ_TYPE.TRIGGER, "cap", "graphics/screens/15_sport/location/cap", 884, 466);
    self:CreateObj(OBJ_TYPE.TRIGGER, "glass", "graphics/screens/15_sport/location/glass", 0, 635);
    self:CreateObj(OBJ_TYPE.TRIGGER, "spoon", "graphics/screens/15_sport/location/spoon", 1084, 973);
    self:CreateObj(OBJ_TYPE.TRIGGER, "thimble", "graphics/screens/15_sport/location/thimble", 1079, 878);
        
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "dumbbell", "graphics/screens/15_sport/location/dumbbell_part", 1014, 371);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "dumbbell_shadow", "graphics/screens/15_sport/location/dumbbell_shadow", 670, 884);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "vaulting_buck", "graphics/screens/15_sport/location/vaulting_buck_part", 852, 765);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "vaulting_buck", "graphics/screens/15_sport/location/vaulting_buck_shadow", 858, 882);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "trophy", "graphics/screens/15_sport/location/trophy_part", 988, 1018);
     self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "trophy_shadow", "graphics/screens/15_sport/location/trophy_shadow", 963, 1026);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "punchbag", "graphics/screens/15_sport/location/punchbag_part", 1473, 421);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "bat15", "graphics/screens/15_sport/location/bat15_part", 1048, 730);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "bat15_shadow", "graphics/screens/15_sport/location/bat15_shadow", 1309, 767);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "grip", "graphics/screens/15_sport/location/grip_part", 540, 1046);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "grip_shadow", "graphics/screens/15_sport/location/grip_shadow", 357, 954);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "racket", "graphics/screens/15_sport/location/racket_part", 40, 128);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rugby", "graphics/screens/15_sport/location/rugby_part", 795, 196);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "whistle", "graphics/screens/15_sport/location/whistle_part", 480, 476);  
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "shuttlecock", "graphics/screens/15_sport/location/shuttlecock_part", 0, 528);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "weight15", "graphics/screens/15_sport/location/weight15_part", 643, 390);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "pin", "graphics/screens/15_sport/location/pin_part", 462, 798);
end