function init(bIsRestart)

	-- Initialise arena - backdrop_name, start_pos, is_restart
	init_level("level-the-kings-road", CCPoint(-50, -20), bIsRestart)

	-- Fall from sky
	if (bIsRestart ~= true) then
		init_fall(bIsRestart)
	end

end

function init_fall(bIsRestart)

	-- Restart here
	if (bIsRestart ~= true) then
		game_manager:setCheckpoint("init_fall")
	else
		-- Do regular level start stuff
		startLevelIntro(bIsRestart)
	end

	player.Height = 40
	player:setFacingDir(kFacingDir_Left)
	player:doAction(kFAT_FallBack)

end

function onLevelIntro()

	-- Wait till fall is complete then do intro speech
	game_manager:startTimer(2, onIntroSpeech)

	bot_manager.MaxBotsOnScreen = 1

end

function onIntroSpeech()

	say("lumberjack", localize("KINGS_ROAD_INTRO_1"), talkToFist)
	say("lumberjack", localize("KINGS_ROAD_INTRO_2"), talkToFist)
--	say("fist", "That was almost definitely the last time.", fistTalk)
--	say("lumberjack", "I hope you're not making this up as you go along.", talkToFist)
	say("fist", localize("KINGS_ROAD_INTRO_3"), fistTalk)
	say("lumberjack", localize("KINGS_ROAD_INTRO_4"), talkToFist)
	say("lumberjack", localize("KINGS_ROAD_INTRO_5"), talkToFist, onLevelIntroEnd)

end

function onNotice1()

	disconnectControlsAndPauseBots()

	say("lumberjack", localize("KINGS_ROAD_POSTER_1_1"), talkToFist)
	say("lumberjack", localize("KINGS_ROAD_POSTER_1_2"), talkToFist)
	say("lumberjack", localize("KINGS_ROAD_POSTER_1_3"), talkToFist)

	say("lumberjack", localize("KINGS_ROAD_POSTER_1_4"), talkToFist, connectControlsAndResumeBots)

	return true

end

function onNotice2()

	disconnectControlsAndPauseBots()

	say("lumberjack", localize("KINGS_ROAD_POSTER_2_1"), talkToFist)
	say("lumberjack", localize("KINGS_ROAD_POSTER_2_2"), talkToFist)
	say("fist", localize("KINGS_ROAD_POSTER_2_3"), fistTalk)
	say("fist", localize("KINGS_ROAD_POSTER_2_4"), fistTalk)
	say("fist", localize("KINGS_ROAD_POSTER_2_5"), fistTalk, connectControlsAndResumeBots)

	return true

end

function onAmbush()

	-- Restart from here
	if (bIsRestart ~= true) then
    
   		-- Make this a bit harder than the last ambush
		bot_manager.MaxBotsOnScreen = bot_manager.MaxBotsOnScreen + 1

		game_manager:setCheckpoint("onAmbush")
	end
                
	-- Spawn regular enemies
	local bot_descs = {}
	table.insert(bot_descs, game_manager:actorDescWithFile("peasant-gruntbear.plist"))

	-- Spawn lots of enemies
	startAmbush(bot_descs, bot_manager.MaxBotsOnScreen * 2)

	return true
	
end

function onBossAmbush()

	-- Restart from here
	if (bIsRestart ~= true) then
		game_manager:setCheckpoint("onBossAmbush")
    end
                
    bot_manager.MaxBotsOnScreen = 5

	-- Spawn regular enemies
	bison_desc = game_manager:actorDescWithFile("bison.plist")

	local bison1_id = bot_manager:addBotToSpawnQueue(bison_desc, kSpawnDir_Right)
	local bison2_id = bot_manager:addBotToSpawnQueue(bison_desc, kSpawnDir_Right)
	local bison3_id = bot_manager:addBotToSpawnQueue(bison_desc, kSpawnDir_Right)

	bot_manager:triggerOnBotEvent(bison1_id, kBotTrigger_Killed, checkStopCameraBlock)
	bot_manager:triggerOnBotEvent(bison1_id, kBotTrigger_Spawned, onBison1Spawned)

	bot_manager:triggerOnBotEvent(bison2_id, kBotTrigger_Killed, checkStopCameraBlock)
	bot_manager:triggerOnBotEvent(bison2_id, kBotTrigger_Spawned, onBison2Spawned)

	bot_manager:triggerOnBotEvent(bison3_id, kBotTrigger_Killed, checkStopCameraBlock)
	bot_manager:triggerOnBotEvent(bison3_id, kBotTrigger_Spawned, onBison3Spawned)

	-- Spawn lots of enemies
--	boss_id = startBossAmbush(bot_descs, "bear")

	disconnectControls()

	say("bison", localize("KINGS_ROAD_BOSS_1"))
	say("lumberjack", localize("KINGS_ROAD_BOSS_1"))
	say("bison", localize("KINGS_ROAD_BOSS_1"))
	say("lumberjack", localize("KINGS_ROAD_BOSS_1"))
	say("bison", localize("KINGS_ROAD_BOSS_1"))
	say("lumberjack", localize("KINGS_ROAD_BOSS_1"))
	say("bison", localize("KINGS_ROAD_BOSS_1"), nil, onBisonAttack)

	return true

end

function onBisonAttack()

	connectControlsAndResumeBots()

-- 	camera_manager:setLeftEdgeCollision(player:getPositionX() - 320)

end

function onBison1Spawned(bot)

	local backdrop = game_manager.Background
	local bot_target = backdrop:getNodeByName("bison1")
	local target_pos = bot_target:getPositionLua()

	bot:setBasePosition(target_pos)

end

function onBison2Spawned(bot)

	local backdrop = game_manager.Background
	local bot_target = backdrop:getNodeByName("bison2")
	local target_pos = bot_target:getPositionLua()

	bot:setBasePosition(target_pos)

end

function onBison3Spawned(bot)

	local backdrop = game_manager.Background
	local bot_target = backdrop:getNodeByName("bison3")
	local target_pos = bot_target:getPositionLua()

	bot:setBasePosition(target_pos)

	bot_manager:pause()
 	camera_manager:setLeftEdgeCollision(player:getPositionX() - 15)

end
