
.namespace s01_c02

function OnEnable()
--	SearchSite.OnEnable()
	Closeup.OnEnable("MiniGame")
	OPLog.Log("OnEnable unit "..self.Name)
	gamestart=false
	if SampleLevel.IsEqual("s01_indice",false) then
		indice.Enabled= false
		
	end
	-- InventoryManager.AddInInventory("InventoryCodeCadenas")
end


function OnUpdate()
	if cadena_1 == 8 and cadena_2 == 3 and cadena_3 == 0 then
	
				 --La condition n'est plus remplie pour eviter une boucle infinie
				 cadena_1 = -1
				PlaySoundEffect("gmp_unlock")
				NavigationManager.SwitchTo(nil,"s04_SearchSite")
				
				InventoryManager.RemoveFromInventory("InventoryCodeCadenas")
		end
end

function OnEnter() 
	SequencePlayer.Enabled = true
	if InventoryCodeCadenas.Equipped == false and SampleLevel.IsEqual("s01_indice",false) then		
		SequencePlayer.PlaySequence("GP_102",self,nil)
		gamestart=false
		return true
	else
		SequencePlayer.PlaySequence("GP_107",self,nil)
		
	end
	
	
	if SampleLevel.IsEqual("s01_indice",true) then
	indice.Enabled= true
	gamestart=true
	end
end

function OnPickObject(objname)

		
end

function OnSearchEnd(typesearch)

end

function CondSpecificToFinish() -- Penser à comprendre à quoi ça sert

end

function OnSequenceEnd(dialogue)
	if dialogue == "GP_102" then
		NavigationManager.SwitchTo(nil,"s01_SearchSite")
	end
	if dialogue == "GP_112" then
		SequencePlayer.PlaySequence("AI_"..GetCurrentManager().Name,self,nil,"help")
	end
	if  UserData.IsEqual("displayTutorial", true) then
		if dialogue == "GP_107" then
			NewTutorialManager.OpenPopupTuto("TU_11",nil,121,384,"waitforanyclic")
			popups_tuto.SetFrame(3)
		end
	end
end


function OnDocumentUse(docname)
	if docname == "InventoryCodeCadenas" then
		OPLog.Log("Test : OnDocumentLeave fonctionne")
		indice.Enabled= true
		SpriteFader.Fade(indice,true,1)
		InventoryManager.RemoveFromInventory("InventoryCodeCadenas")
		SampleLevel.Set("s01_indice",true)
		gamestart=true
		SequencePlayer.PlaySequence("GP_112",self,nil)
			 -- InventoryCodeCadenas.Equipped == false
			-- SequencePlayer.Enabled = true
		-- SequencePlayer.PlaySequence("GP_405",self,nil)
		return true
	end
	return false
end

function OnPopupTutoLeave(message)
OPLog.Log("test"..message)
	if  UserData.IsEqual("displayTutorial", true) then
		if message == "TU_11" then
			NewTutorialManager.OpenPopupTuto("TU_12",nil,174,541,"waitforanyclic")
			popups_tuto.SetFrame(0)
		end
	end
	if  UserData.IsEqual("displayTutorial", true) then
		if message == "TU_12" then
			NewTutorialManager.OpenPopupTuto("TU_13",nil,174,20,"waitforanyclic")
			popups_tuto.SetFrame(1)
		end
	end
	if  UserData.IsEqual("displayTutorial", true) then
		if message == "TU_13" then
			NewTutorialManager.OpenPopupTuto("TU_14",nil,686,29,"waitforanyclic")
			popups_tuto.SetFrame(4)
		end
	end
end