function init(is_restart)

	-- Initialise arena - backdrop_name, start_pos, is_restart
	init_level("level-planet-of-the-bears", CCPoint(-70, -20), is_restart)

end

function onLevelIntro()

	bot_manager.MaxBotsOnScreen = 1
	say("lumberjack", localize("BEARHATTAN_SPEECH_1"), talkToFist)
	say("fist", localize("BEARHATTAN_SPEECH_2"), fistTalk)
	say("fist", localize("BEARHATTAN_SPEECH_3"), fistTalk)
	say("fist", localize("BEARHATTAN_SPEECH_4"), fistTalk)
	say("fist", localize("BEARHATTAN_SPEECH_5"), fistTalk)
	say("lumberjack", localize("BEARHATTAN_SPEECH_6"), talkToFist, onLevelIntroEnd)

end

function onThrowTutorial()

	-- Spawn bad guy
	local bot_id = spawnEnemy("warriors-gruntbear", kSpawnDir_Right, false)

	

--   	game_manager:startTimer(2, function() hud:hideRightThumb() end)

	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Spawned, onThrowTutorialEnemySpawned)		


	-- When bad guy stunned tell player to walk into bad guy
	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Stunned, onThrowTutorialEnemyStunned)		
	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_StunnedFinished, onThrowTutorialEnemyStunnedFinished)

	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Grabbed, onThrowTutorialEnemyGrabbed)		
	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_GrabbedFinished, onThrowTutorialEnemyGrabbedFinished)

	bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Killed, onThrowTutorialEnemyKilled)		

	-- Tap to kick in crotch

	-- Swipe to throw

	return true

end

function onThrowTutorial2()

-- Tell player to kick bad guy

	hud:showRightThumb(localize("TUTORIAL_KICK_TO_STUN"))

	game_manager:setGameSpeedMod(0.1)

	game_manager:startTimer(3, function () game_manager:updateGameModSpeed() end)

	return true
end

function onThrowTutorialEnemySpawned(bot)

	tutorial_enemy = bot
	local target_pos = player:getBasePosition()
	bot:setTargetPosition(CCPoint(target_pos.x + 50, target_pos.y))
	bot:setTargetPositionLocked(true)

end

function onThrowTutorialEnemyStunned(bot)

	hud:showLeftThumb(localize("TUTORIAL_WALK_AND_GRAB"))

	game_manager:setGameSpeedMod(0.1)

	game_manager:startTimer(3, function () onResumeAfterEnemyStunned() end)

end

function onResumeAfterEnemyStunned()

--	tutorial_enemy:delayCurrentAction(20)

	game_manager:updateGameModSpeed()

end

function onThrowTutorialEnemyStunnedFinished(bot)

	-- bot_id = bot_manager:getBotID(bot)
	-- bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Stunned, onThrowTutorialEnemyStunned)
	-- bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_StunnedFinished, onThrowTutorialEnemyStunnedFinished)

	bot:setTargetPositionLocked(false)
--	hud:hideLeftThumb()

end

function onThrowTutorialEnemyGrabbed(bot)

	bot:delayCurrentAction(20)

	if (game_manager:isUsingTouchControls()) then
		hud:showRightThumb(localize("TUTORIAL_THROW_TOUCH"))
	else
		local button_punch = game_manager:getGamepadButtonString(kFistInput_Punch);
		local button_kick = game_manager:getGamepadButtonString(kFistInput_Kick);
		local text = localize("TUTORIAL_THROW_BUTTON")
   		hud:showRightThumb(string.format(text, button_punch, button_kick))
	end

end

function onThrowTutorialEnemyGrabbedFinished(bot)

	-- bot_id = bot_manager:getBotID(bot)
	-- bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_Grabbed, onThrowTutorialEnemyGrabbed)
	-- bot_manager:triggerOnBotEvent(bot_id, kBotTrigger_GrabbedFinished, onThrowTutorialEnemyGrabbedFinished)

	game_manager:startTimer(1, function () hud:hideRightThumb() end)
	bot:setTargetPositionLocked(false)

end

function onThrowTutorialEnemyKilled(bot)

	hud:hideRightThumb()

	onAmbush(false)

end


function onBareBears()

	-- Pause player movement
	disconnectControlsAndPauseBots()

	say("lumberjack", localize("BEARHATTAN_BARE_BEARS_1"), talkToFist)
	say("fist", localize("BEARHATTAN_BARE_BEARS_2"), fistTalk, connectControlsAndResumeBots)

	return true

end

function onTimPoster()

	-- Pause player movement
	disconnectControlsAndPauseBots()

	say("lumberjack", localize("BEARHATTAN_POSTER_1"), talkToFist)
	say("fist", localize("BEARHATTAN_POSTER_2"), fistTalk)
	say("lumberjack", localize("BEARHATTAN_POSTER_3"), talkToFist)
	say("fist", localize("BEARHATTAN_POSTER_4"), fistTalk)
	say("lumberjack", localize("BEARHATTAN_POSTER_5"), nil, connectControlsAndResumeBots)

--	say("fist", "They don't mention your GIANT ALL-POWERFUL FIST!", connectControlsAndResumeBots)

	return true

end


function onAmbush(bIsRestart)

	-- 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 bad guys
	local bot_descs = {}
	table.insert(bot_descs, game_manager:actorDescWithFile("warriors-gruntbear.plist"))
	startAmbush(bot_descs, bot_manager.MaxBotsOnScreen * 2)

	return true

end

function onBossAmbush(bIsRestart)

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

	-- Spawn boss dude & his mates
	local bot_descs = {}
	table.insert(bot_descs, game_manager:actorDescWithFile("warriors-gruntbear.plist"))
	boss_id = startLevelBossFight("warriors-bear", bot_descs, bIsRestart, true)

	return true

end

function onLevelBossSpeech()

	say("warriors-bear", localize("BEARHATTAN_BOSS_1"))
	say("lumberjack", localize("BEARHATTAN_BOSS_2"))
	say("warriors-bear", localize("BEARHATTAN_BOSS_3"))
	say("lumberjack", localize("BEARHATTAN_BOSS_4"))
	say("warriors-bear", localize("BEARHATTAN_BOSS_5"), nil, onLevelBossSpeechEnd)

end


function speech()

--[[
	"It's a mad house! A MAD HOUSE!"

	"So what the deal with all the crazy animals."
	"They are a menace. A walking pestilence."
	"I guess they do seem a bit tetchy."

	"'BARE BEARS'?! I just threw up in my mouth."
	"I know, I can taste it. It's quite revolting."

	"Your body smells odd. A bit like turnip."
	"Get out and get your own body then!"

	"YOU MANIACS! YOU BLEW IT UP! AH, DAMN YOU! DAMN YOU TO HELL!"
]]--
end
