-- call animations when touch and touch ended

local function onPartTouched(otherPart, screenGui)
	if(otherPart.Name == "HumanoidRootPart") then
		local frame = screenGui.Frame
		local fill = screenGui.Fill
		local title = screenGui.Title
		local body = screenGui.Body
		local plantFrame = screenGui["Plant Circle"]
		local plant = screenGui["Plant Circle"].Plant
		
		UITween.size(frame, frameMid, 0.25, 0, false)
		UITween.size(fill, frameMid, 0.25, 0, false)

		UITween.fadeText(body, 0, 0.25, 0.25)
		UITween.fadeText(title, 0, 0.25, 0.25)
		UITween.size(frame, frameEnd, 0.25, 0.25, false)
		UITween.fadeBackground(title, 0.6, 0.25, 0.25)

		UITween.fade(plant, 0, 0.25, 0.5)
		UITween.fade(plantFrame, 0, 0.25, 0.5)
		UITween.size(fill, fillEnd, 0.25, 0.5, false)
	end
end

local function onPartTouchedEnded(otherPart, screenGui)
	if(otherPart.Name == "HumanoidRootPart") then
		local frame = screenGui.Frame
		local fill = screenGui.Fill
		local title = screenGui.Title
		local body = screenGui.Body
		local plantFrame = screenGui["Plant Circle"]
		local plant = screenGui["Plant Circle"].Plant

		UITween.fadeText(body, 1, 0.25, 0)
		UITween.fadeText(title, 1, 0.25, 0)
		UITween.fadeBackground(title, 1, 0.25, 0)
		UITween.fade(plant, 1, 0.25, 0)
		UITween.fade(plantFrame, 1, 0.25, 0)
		UITween.size(frame, frameMid, 0.25, 0, false)
		UITween.size(fill, frameMid, 0.25, 0, false)
		UITween.size(frame, frameStart, 0.25, 0, false)
		UITween.size(fill, frameStart, 0.25, 0, false)
	end
end


function InteractFact.Init(model)
	local part = model.ScreenTouchPart
	local screenGui = model.PlantScreen.SurfaceGui
	
	-- default sizes
	screenGui.Body.TextTransparency = 1
	screenGui.Title.BackgroundTransparency = 1
	screenGui.Title.TextTransparency = 1
	screenGui.Frame.Size = frameStart
	screenGui.Fill.Size = frameStart
	screenGui["Plant Circle"].ImageTransparency = 1
	screenGui["Plant Circle"].Plant.ImageTransparency = 1	
	
	-- add listeners, that will call a generic function passing specific screenGui
	part.Touched:Connect(function(otherPart)onPartTouched(otherPart, screenGui) end)
	part.TouchEnded:Connect(function(otherPart) onPartTouchedEnded(otherPart, screenGui) end)
end

return InteractFact
