layoutWoods2.bobCatScareStarted = false
layoutWoods2.scareRavenFrametime = 100
layoutWoods2.scareRavenWaitTime = 1
layoutWoods2.shouldShowRaven = false
layoutWoods2.shownScareRaven = false
-- ----------------------------------------------------------------------------
layoutWoods2.mExits =
{
	[objectExitWoods2Lakeside] = 
	{
		target = layoutLakeside,
		arrowX = 532,
		arrowY = 490,
		arrowAngle = 1.7 * math.pi,
		labelX = 524,
		labelY = 436,
		labelAnchorpoint = ANCHOR_CENTER_LEFT,
	},
	[objectExitWoods2Woods1] = 
	{
		target = layoutWoods1,
		targetPageH = kRight,
		arrowX = 619,
		arrowY = 622,
		arrowAngle = 1.15 * math.pi,
		labelX = 691,
		labelY = 609,
		labelAnchorpoint = ANCHOR_CENTER_LEFT,
	},
}

layoutWoods2.mPOIs = 
{
	[objectPoiBobcatCave] = 
	{
		target = layoutWoods2BobcatCave,
	},
	[objectPoiFenceHole01] = 
	{
		target = layoutCemeteryFence,
		mirrors = {objectPoiFenceHole02, objectPoiFenceHole03}
	},
	[objectPoiKindling] = 
	{
		target = layoutWoods2Sticks,
		mirrors = {objectPoiKindlingSolved}
	},
}

layoutWoods2.mHOs = 
{
	[objectHoLongStick] = 
	{
		siblings = {objectHoLongStickPocket}
	},
	[objectHoRock01] = 
	{
		siblings = {objectHoRock01Lit, objectHoRock01Pocket}
	},
	[objectHoRock02] = 
	{
		siblings = {objectHoRock02Lit}
	},
	[objectHoRock03] = 
	{
		siblings = {objectHoRock03Lit}
	},
	[objectHoRag] =
	{
	},	
}

layoutWoods2.mIOs =
{
	[objectIoLongStick] = 
	{
		cursor = kCursorDefault
	}
}
-- ----------------------------------------------------------------------------
function layoutWoods2:onConstruct()
	
	Layout.onConstruct(self)
	
	p = self:newChildParticle( { name = "PARTICLE_WOODS2_OUTSIDE_MIST", x=0, y=420, library="PARTICLE_OUTSIDE_MIST", section="particles", play=true } )
	p:addInitialTime(30000)
	p:moveBehind(objectBackgroundWoods2Front)
	
end
-- ----------------------------------------------------------------------------
function layoutWoods2:onInitialize()

	Layout.onInitialize(self)
	
	objectExitWoods2Lakeside:ss(kActive)
	objectExitWoods2Woods1:ss(kActive)

	objectPoiFenceHole01:ss(kIdle)
	objectPoiFenceHole02:ss(kInactive)
	objectPoiFenceHole03:ss(kInactive)
	objectHoRag:ss(kIdle)
	
	objectWoods2BobcatA:ss(kInactive)
	objectWoods2BobcatB:ss(kInactive)
	objectWoods2BobcatC:ss(kInactive)

	objectBobcatEyes:ss(kInactive)
	
	objectScareWoods2RavenStart:ss(kInactive)
	objectScareWoods2RavenA:ss(kInactive)
	objectScareWoods2RavenB:ss(kInactive)
	objectScareWoods2RavenC:ss(kInactive)
	
	objectIoLongStick:ss(kInactive)
	
	objectPoiKindlingSolved:ss(kInactive)
	
	objectPaperFence:ss(kInactive)

end
-- ----------------------------------------------------------------------------
function layoutWoods2:onClickIO(object, x, y)

	return Layout.onClickIO(self, object, x, y)
	
end
-- ----------------------------------------------------------------------------
function layoutWoods2:onShow()
	
	Layout.onShow(self)
	
	if (self.shouldShowRaven and self.shownScareRaven == false and not objectScareWoods2RavenStart:isDone()) then
		
		self:startRavenScare()
	
	end
		
end

-- ----------------------------------------------------------------------------
function layoutWoods2:startRavenScare()
	
	self.shownScareRaven = true
	
	objectScareWoods2RavenStart:ss(kIdle)
	objectScareWoods2RavenStart:animate("scareWoods2RavenStart_blocking",
		{ delay=self.scareRavenWaitTime	}
	)
	
end
-- ----------------------------------------------------------------------------
function layoutWoods2:startBobcatScare()
	
	if (self.bobCatScareStarted == false) then
		self.bobCatScareStarted = true
		
		objectWoods2BobcatB:setAlpha(0)
		objectWoods2BobcatB:ss(kIdle)
		objectWoods2BobcatC:setAlpha(0)
		objectWoods2BobcatC:ss(kIdle)
		
		-- Scare moment:
		objectWoods2BobcatA:ss(kIdle)
		objectWoods2BobcatA:animate("scareWoods2Bobcat1_blocking",
			{ delay=1000										},
			{ command="playTrack track=ANGRY_BOBCAT", target=self	},
			{ startframe=1, 		frametime=700				}
		)
		
	end

end
-- ----------------------------------------------------------------------------
function layoutWoods2:animPaper()

	if (objectPaperFence:isIdle()) then
		objectPaperFence:animate("flapPaperWoods2",
			{ delay = math.random(4500, 8000) },
			{ startframe=0, endframe=10, frametime=75 }
		)		
	end

end
-- ----------------------------------------------------------------------------
function layoutWoods2:onAnimationFinish(animationName)

	Layout.onAnimationFinish(self, animationName)
	
	if (animationName == "flapPaperWoods2") then
		self:animPaper()
	
	elseif (animationName == "scareWoods2Bobcat1_blocking") then
		objectWoods2BobcatA:ss(kDone)
		
		objectWoods2BobcatB:setAlpha(1)
		objectWoods2BobcatB:animate("scareWoods2Bobcat2_blocking",
			{ startframe=0, endframe=2,		frametime=150				}
		)
	
	elseif (animationName == "scareWoods2Bobcat2_blocking") then
		objectWoods2BobcatB:ss(kDone)
		
		objectWoods2BobcatC:setAlpha(1)
		objectWoods2BobcatC:animate("scareWoods2Bobcat3_blocking",
			{ startframe=0, 		frametime=150				}
		)
	
	elseif (animationName == "scareWoods2Bobcat3_blocking") then
		objectWoods2BobcatC:ss(kDone)
		
		objectPoiBobcatCave:ss(kActive)
		objectIoCaveHitarea:ss(kActive)
		objectBobcatEyes:ss(kIdle)
		objectCaveBobcat:ss(kIdle)
		layoutWoods2BobcatCave:blinkEyes()
	
	elseif (animationName == "scareWoods2RavenStart_blocking") then
		
		objectScareWoods2RavenStart:ss(kDone)
		objectScareWoods2RavenA:ss(kIdle)
	
		objectScareWoods2RavenA:animate("scareWoods2RavenA_blocking",
			{ command="playTrack track=RAVEN_FLY_ACROSS", target=self },
			{ startframe=0, endframe=4,		frametime=self.scareRavenFrametime	}
		)
	
	elseif (animationName == "scareWoods2RavenA_blocking") then
		
		objectScareWoods2RavenA:ss(kDone)
		objectScareWoods2RavenB:ss(kIdle)
		
		objectScareWoods2RavenB:animate("scareWoods2RavenB_blocking", 
			{ startframe=0, endframe=1,		frametime=self.scareRavenFrametime	}
		)
		
	elseif (animationName == "scareWoods2RavenB_blocking") then
		
		objectScareWoods2RavenB:ss(kDone)
		objectScareWoods2RavenC:ss(kIdle)
		
		objectScareWoods2RavenC:animate("scareWoods2RavenC_blocking", 
			{ startframe=0, endframe=2,		frametime=self.scareRavenFrametime	}
		)
	
	elseif (animationName == "scareWoods2RavenC_blocking") then

		objectScareWoods2RavenC:ss(kDone)
		
	end
	
end

-- ----------------------------------------------------------------------------
function layoutWoods2:onStartAudio()

	-- Play some outside noises
	playAmbientAudio(kOutsideHutAmbientGroup)
	
	-- Sweeteners
	local tempTrack = {}
	
	tempTrack.group = kOutsideHutAmbientGroup
	tempTrack.volume = 1.0
	
	tempTrack.tag = "TREES"
	tempTrack.definition = "TREE_SWEETENER_1"
	getAudioManager():playTrack(tempTrack)
	
	tempTrack.tag = "CONES"
	tempTrack.definition = "PINECONE_FALL"
	getAudioManager():playTrack(tempTrack)
	
	tempTrack.tag = "TWIGS"
	tempTrack.definition = "TWIG_CRACK"
	getAudioManager():playTrack(tempTrack)
	
end

-- ----------------------------------------------------------------------------
function layoutWoods2:onStopAudio()
	stopAudioTrack("TREES")
	stopAudioTrack("CONES")
	stopAudioTrack("TWIGS")
end
-- ----------------------------------------------------------------------------
function layoutWoods2:onClickLocked(object, x, y)

	if (not goalGetAway:isActive()) then
		if (object == objectPoiBobcatCave) then
			think("MESSAGE_ANIMALDEN")
			return false
		end
	end
	
	return Layout.onClickLocked(self, object, x, y)

end