GameScreen.textures_path = "graphics/screens/20_wizard/location/"

GameScreen.hint_table = { 
    {obj = {"house_hint", 343, 358}, fun = function() if(GetState(CURRENT_SCREEN, "state") == "wait") then return true end end}, 
}

function GameScreen:RestoreScene()
    --SetState(CURRENT_SCREEN, "state", "after_30")
    
    --if(GetState(CURRENT_SCREEN, "state") ~= "") then
        self:AddHiddenCrystal("crystal_20_part")
    --end
    
    if(GetState(CURRENT_SCREEN, "state") == "") then
        local comics_finish = function()
            --self:AddHiddenCrystal("crystal_20_part")
            SetState("screen_019_house", "state", "wood1")
            SetState(CURRENT_SCREEN, "state", "wait")
            Inventory:save_tool("key_020", true)
                
            DelayedExec(1.0, function()
                clApplication.curret_win = clScreenManager:add_screen("tool_found_screen") 
                clApplication.curret_win._resource = "graphics/screens/20_wizard/location/object_found_20"
                clApplication.curret_win.end_fun = function()
                    Inventory:ToolFound("key_020", 800, 600)
                    
                    --DelayedExec(1.0, function()
                    --    clApplication:LoadLocation("019_house")
                    --end, 113)
                end
                
            end, 113)
        end
        local comics = clScreenManager:add_screen("020_wizard_dlg_1") 	
        comics.on_finish = comics_finish;
    elseif(GetState(CURRENT_SCREEN, "state") == "wait") then
        
    elseif(GetState(CURRENT_SCREEN, "state") == "after_30") then
        local comics_finish = function()
            SetState(CURRENT_SCREEN, "state", "screen_30")

            DelayedExec(1.0, function()
                self:StartHO();
            end, 113)
        end
        local comics = clScreenManager:add_screen("020_wizard_dlg_2") 	
        comics.on_finish = comics_finish;
    elseif(GetState(CURRENT_SCREEN, "state") == "screen_30") then
        self:StartHO()
    elseif(GetState(CURRENT_SCREEN, "state") == "finish") then
        clApplication:LoadLocation("Intro_06")
    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()       
         
    self:RestoreScene();

    self:SetItemSound("bottle_08", "sound/bottle_07.ogg");
    self:SetItemSound("bottle_03", "sound/bottle_05.ogg");
    self:SetItemSound("bottle_02", "sound/bottle_06.ogg");
    self:SetItemSound("bottle_07", "sound/bottle_04.ogg");
    self:SetItemSound("wizard_sphere", "sound/wizard_sphere.ogg");
    self:SetItemSound("bottle_01", "sound/bottle_03.ogg");
    self:SetItemSound("bottle_05", "sound/bottle_01.ogg");
    self:SetItemSound("ceramic_pot", "sound/ceramic_pot_01.ogg");
    self:SetItemSound("lamp_aroma", "sound/lamp_aroma.ogg");
    self:SetItemSound("bedpan", "sound/bedpan.ogg");

    self:CreateLocationPortal("goto_19", "019_house", "hand")
    
    MusicPlay({"sound/ambient/20_ambient.ogg", "sound/music/past.ogg"} , 20) 
end

---------------------------------------------------------------------
function GameScreen:StartHO()
    local ho_end = function()  
        DelayedExec(1.5, function()
            local comics_finish = function()
                SetState("screen_chapters_screen", "current_chapter", "6")
                clApplication:LoadLocation("chapters_screen")
            end
            local comics = clScreenManager:add_screen("020_wizard_dlg_3") 	
            comics.on_finish = comics_finish;
        end, 113)
        self.mini_game = nil;
        SetState(CURRENT_SCREEN, "state", "finish")
    end

    self.item_list = {
        {obj = {"magic_wand", {x = 16, y = 231}}, },
        {obj = {"woodlouse", {x = 720, y = 599}}, },
        {obj = {"coconut", {x = 19, y = 197}}, },
        {obj = {"tentacle", {x = 921, y = 231}}, },
        {obj = {"rock", {x = 1215, y = 737}}, },
        {obj = {"egg", {x = 1461, y = 444}}, },
        {obj = {"strobile", {x = 311, y = 240}},},
        {obj = {"vial", {x = 278, y = 702}}, },
        {obj = {"claw", {x = 1178, y = 459}}, },
        {obj = {"bone", {x = 617, y = 944}}, },
        {obj = {"starfish", {x = 897, y = 1008}}, },
        {obj = {"skeleton", {x = 982, y = 717}}, },
    }

    self:SetMiniGame(mgt_hidden_object)   
    self.mini_game:Init(self.item_list, ho_end);
end

function GameScreen:OnFinish()
end
------------------------------------------------------------------------------------------------------
-------------------------------------------Mouse functions--------------------------------------------
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
function GameScreen:LoadScreen()
	--[[---Background---]]--
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "20_wizard", "graphics/screens/20_wizard/location/20_wizard",0, 0);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_08", "graphics/screens/20_wizard/location/bottle_08",459, 864);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_03", "graphics/screens/20_wizard/location/bottle_03",547, 841);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_02", "graphics/screens/20_wizard/location/bottle_02",745, 638);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_07", "graphics/screens/20_wizard/location/bottle_07",959, 822);
    self:CreateObj(OBJ_TYPE.TRIGGER, "wizard_sphere", "graphics/screens/20_wizard/location/wizard_sphere",1119, 617);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_01", "graphics/screens/20_wizard/location/bottle_01",1240, 346);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bottle_05", "graphics/screens/20_wizard/location/bottle_05",1339, 127);
    self:CreateObj(OBJ_TYPE.TRIGGER, "ceramic_pot", "graphics/screens/20_wizard/location/ceramic_pot",1209, 197);
    self:CreateObj(OBJ_TYPE.TRIGGER, "lamp_aroma", "graphics/screens/20_wizard/location/lamp_aroma",466, 256);
    self:CreateObj(OBJ_TYPE.TRIGGER, "bedpan", "graphics/screens/20_wizard/location/bedpan",1312, 1113);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "crystal_20_part", "graphics/screens/20_wizard/location/crystal_20_part", 1501, 1002);
    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "magic_wand", "graphics/screens/20_wizard/location/magic_wand_part",75, 279);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "woodlouse", "graphics/screens/20_wizard/location/woodlouse_part",764, 626);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "tentacle", "graphics/screens/20_wizard/location/tentacle_part",923, 251);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "rock", "graphics/screens/20_wizard/location/rock_part",1271, 773);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "egg", "graphics/screens/20_wizard/location/egg_part",1504, 481);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "strobile_shadow", "graphics/screens/20_wizard/location/strobile_shadow",316, 279);    
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "strobile", "graphics/screens/20_wizard/location/strobile_part",338, 271);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "vial", "graphics/screens/20_wizard/location/vial_part",287, 765)  
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "claw", "graphics/screens/20_wizard/location/claw_part",1197, 478); 
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "bone", "graphics/screens/20_wizard/location/bone_part",643, 978);  
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "starfish", "graphics/screens/20_wizard/location/starfish_part",936, 1041);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "starfish_shadow", "graphics/screens/20_wizard/location/starfish_shadow",936, 1044); 
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "skeleton", "graphics/screens/20_wizard/location/skeleton_part",1008, 736);
    self:CreateObj(OBJ_TYPE.ACTIVE_ALL, "coconut", "graphics/screens/20_wizard/location/coconut_part",48, 223);
    
    self:CreateObj(OBJ_TYPE.TRIGGER, "goto_19", "graphics/screens/20_wizard/location/house_eye", 357, 373);
    
    clScreenManager:add_screen("hud")   
end
