
-- Funcion que carga el directorio de las texturas
-----------------------------------------------------------------------------
function preLoadGameTextures()
    local mainTexturePath = getTexturesPath();
    
    preLoadTexturesFromDir( mainTexturePath );
    preLoadTexturesFromDir( mainTexturePath .. "LightMaps/");
    preLoadTexturesFromDir( mainTexturePath .. "Particles/");
    preLoadTexturesFromDir( mainTexturePath .. "GUI/");
    preLoadTexturesFromDir( mainTexturePath .. "GUI/Achivements/");
    preLoadTexturesFromDir( mainTexturePath .. "GUI/Menu/");
    preLoadTexturesFromDir( mainTexturePath .. "GUI/Intro/");
    
return 0;
end

-- Funcion inicial, se llama al cargar el juego
-----------------------------------------------------------------------------
function init( )
  checkPointPos = Vector3( 36, 2, 18 );
  unHidePlatform("trackerPlatform_scriptedLake_01");

  --------------------------------------------------------------- Variables de control del scripting
  -- To Control on_firstEnter in checkpoints
  init_CheckPointTriggersVariables();
  isEnter_CheckPoint17 = false;
  
  Init_Achivements();
  
  -- To Control on_first_step
  isFirstStep_trackerPlatform_static_01 = false;
  isFirstStep_trackerPlatform_static_02 = false;
  isFirstStep_trackerPlatform_static_03 = false;
  isFirstStep_trackerPlatform_translate_04 = false;
  
  isFirstStep_trackerPlatforms_Stage3 = false;

  -- Les plataformes del ultim nivell
  isFirstStep_platform_horitzontal_05_grass = false;
  isFirstStep_platform_horitzontal_16_grass = false;
  isFirstStep_platform_horitzontal_2_05_rock = false;
  isFirstStep_platform_horitzontal_2_03_rock = false;
  isFirstStep_platform_horitzontal_28_grass = false;
  isFirstStep_platform_horitzontal_2_08_rock = false;
  isFirstStep_platform_horitzontal_2_60_rock = false;
  isFirstStep_platform_horitzontal_29_grass = false;
  
  isEnabled_BaseBallGameplay = false;
  isReached_FirstStep_BaseBallGameplay = false;
  isReached_SecondStep_BaseBallGameplay = false;
  isReached_BaseBallGameplay = false;
  
  isReached_FinalBattle = false;
  
  -- Control de onFirstEnter als triggers
  isFirstEnter_trigger_cutScene02 = true;
  isFirstEnter_trigger_cutScene03 = true;
  isFirstEnter_trigger_cutScene04 = true;
  
  isAlternativePathLakeVisited = false;
  
  isTrigger_FollowPath01_enabled = false;
  isTrigger_FollowPath02_enabled = false;
  isTrigger_FollowPath03_enabled = true;
  isTrigger_FollowPath04_enabled = true;
  isTrigger_FollowPath05_enabled = false;
  isTrigger_FollowPath06_enabled = true;
  isTrigger_FollowPath07_enabled = false;
  isTrigger_FollowPath08_enabled = true;
  isTrigger_FollowPath09_enabled = true;
  isTrigger_FollowPath12_enabled = true;
  isTrigger_FollowPath13_enabled = true;
  isTrigger_FollowPath14_enabled = true;
  isTrigger_FollowPath19_enabled = true;
  
  -- Triggers walkOnWater
  isTrigger_FollowPath15_enabled = true;
  isTrigger_FollowPath16_enabled = true;
  isTrigger_FollowPath17_enabled = true;
  isTrigger_FollowPath18_enabled = true;
  
  isTrigger_trigger_finalBossStage2_Right_enabled = false;
  isTrigger_trigger_finalBossStage2_Left_enabled = false;
  
  isTrigger_AlternativePath_enabled = false;
  
  -- addEnemy( "MegaWhiteShark", Vector3(-87.686, 6.0838, -125.895) )
  invalidateEntityByName( "MegaWhiteShark" )
  
  -- moure el player a la plataforma del final boss
  --setPlayerPosition( Vector3( -85.686, 6.0838, -123.895) )
  
  setCagesTypes( );
  unhideInitialEnemiesLvl1( );
  
  StartCutScene01();
  
  -- TODO(Important): Treure aixo si lo de dalt esta actiu
	--start_Lvl1();
  --
  
  unlockPathToStaticPlatform01();
  
  --incrementWptScriptedPlatform("trackerPlatform_scriptedLake_01")
  --incrementWptScriptedPlatform("trackerPlatform_scriptedLake_01")
  --setEntityPositionByName("trackerPlatform_scriptedLake_01", Vector3(-101.86, 52.087, 3.642))
  
  --hideLvl1Platforms( );
  --hideLvl2Platforms( );
  -- On_Activate_Switch02( );
  -- On_Activate_Switch03( );
  
  -- Init the parameters of some entities
  setValidationOfEntities();
  associateEntitiesToTrackers();
  disableParticleEmiters();
  disableCollsionsOfEntities();
  
  -- Enable/Disable instanceBoxes based on visiblity
  setInstanceBoxValidByName("lakeplants1", true);
  setInstanceBoxValidByName("lakeplants2", false);
  setInstanceBoxValidByName("lakeplants3", false);
  
  setInstanceBoxValidByName("InstanceBox_03", false);
  
  setInstanceBoxValidByName("elements_plano2_lvlG", true);
  setInstanceBoxValidByName("elements_plano2_lvl1", true);
  setInstanceBoxValidByName("elements_plano2_lvl2", false);
  setInstanceBoxValidByName("elements_plano2_lvl3", false);
  
  setInstanceBoxValidByName("elements_geo.2_lvl1", true);
  
  -- S'activa al sortir del trunk del lvl1
  setInstanceBoxValidByName("elements_geo.2_lvl2", false);
  setInstanceBoxValidByName("elements_geo.2_lvl3", false);
  
  -- Variables to control flux in finalBattle
  is_throwBattleSequence1_End = false;
  is_killed_EnemiesInBattleSequence1 = false;
  
  is_throwBattleSequence2_End = false;
  is_killed_EnemiesInBattleSequence2 = false;
  
  is_throwBattleSequence3_End = false;
  is_killed_EnemiesInBattleSequence3 = false;
  
  -- Variables to control flux in finalBossBattle
  is_in_Stage1_finalBoss = false;
  is_in_Stage2_finalBoss = false;
  is_in_EndStage2_finalBoss = false;
  is_in_Stage3_finalBoss = false;
  is_in_Stage4_finalBoss = false;
  is_in_End_finalBoss = false;
  
  -- Recuperem la camera default del player
  setCameraMode( 0, "", "", 0.0 );
  
  -- Activem els sistemes de particules que es veuen
  setEntityValidByName("PsEmiter_water_impact01", true);
  setEntityValidByName("PsEmiter_water_impact02", true);
  setEntityValidByName("PsEmiter_water_impact03", true);
  setEntityValidByName("PsEmiter_water_impact04", true);
  setEntityValidByName("PsEmiter_water_impact05", true);
  setEntityValidByName("PsEmiter_water_impact06", true);
  
  -- Guardem l'estat de les instancies un cop aplicat el init
  saveStateOfAllGameInstances();
  
return 0;
end

function initMenu( )

  -- Events de musica
  startMenuMusic();
  
  activateGUIMainMenu( false );

  local functionOrder;
  
  functionOrder = "setCameraModeBlendInfo( 6, \"tracker_targetMenuBarrel_Init\", \"trackerCamera_menuBarrel_Init\", 0.0, 0.0, 0.0 )";
  addOrderToSequencer ( functionOrder, 0.0 );
  
  functionOrder = "activateGUIDialog(\"Title_Dialog\", true)"
  addOrderToSequencer ( functionOrder, 2.0 );
  
  -- Ajustamos la camera
  functionOrder = "setCameraModeBlendInfo( 2, \"tracker_menuBarrel\", \"trackerCamera_menuBarrel\", 100.0, 0.95, 0.97 )";
  addOrderToSequencer ( functionOrder, 3.0 );
  
  functionOrder = "activateGUIDialog(\"Title_Dialog\", false)"
  addOrderToSequencer ( functionOrder, 2.0 );
  
  functionOrder = "activateGUIMainMenu( true )";
  addOrderToSequencer ( functionOrder, 1.0 );
  
return 0;
end

-- Funció general
----------------------------------------------------------------------------
function setToNoVisibleLvl1Elements( )
	setEntityVisibleByName( "Line21", false );
	setEntityVisibleByName( "Line16", false );
	setEntityVisibleByName( "Line03", false );
	setEntityVisibleByName( "Line02", false );
	setEntityVisibleByName( "Line08", false );
	setEntityVisibleByName( "bridge", false );
	setEntityVisibleByName( "Object01", false );
return 0;
end

-- Prueba de crear enemigos, funciona pero no se ven o_O, aunque disparan piñas
-----------------------------------------------------------------------------
function createEnemy( )
  addEnemy( "Octopus", Vector3(-1, 0, 13) );
return 0;
end

-- Respuesta a Triggers 1a Zona - Playa
------------------------------------------------------------------------------
function On_Enter_trigger_beachStart( )

	local player = getMainPlayer();
	
	if( areActionsWithKeyBoard() == true  ) then
		setComicDialog( getMainPlayer(), "info_salt");
	elseif( areActionsWithPad() == true  ) then
		setComicDialog( getMainPlayer(), "info_salt_pad");
	else
		setComicDialog( getMainPlayer(), "info_salt_mouse");
	end

return 0;
end

function On_Exit_trigger_beachStart( )

	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );

	setCameraMode( 0, "", "", 0.0 );
	
return 0;
end

function On_Enter_trigger_beachStart02( )

	local player = getMainPlayer();
	
	if( areActionsWithKeyBoard() == true ) then
		setComicDialog( getMainPlayer(), "info_attack");
	elseif( areActionsWithPad() == true ) then
		setComicDialog( getMainPlayer(), "info_attack_pad");
	else
		setComicDialog( getMainPlayer(), "info_attack_mouse");
	end
	
	setCameraMode( 0, "", "", 0.0 );

return 0;
end

function On_Exit_trigger_beachStart02( )

	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );
	
	setCameraMode( 0, "", "", 0.0 );

return 0;
end

function On_Enter_trigger_beachStart03( )

	local enemy = getEnemyByName("Octopus16_scary");
	
	if( areActionsWithKeyBoard() == true ) then
		setComicDialog( enemy, "info_picat");
	elseif( areActionsWithPad() == true  ) then
		setComicDialog( enemy, "info_picat_pad");
	else
		setComicDialog( enemy, "info_picat_mouse");
	end
	
	setCameraMode( 0, "", "", 0.0 );

return 0;
end

function On_Exit_trigger_beachStart03( )

	local enemy = getEnemyByName("Octopus16_scary");
	setVisiblityComicDialog( enemy, false );
	
	setCameraMode( 0, "", "", 0.0 );

return 0;
end

function On_Enter_trigger_beachStart04( )

	local player = getMainPlayer();
	
	if( areActionsWithKeyBoard() == true ) then
		setComicDialog( getMainPlayer(), "info_twister");
	elseif( areActionsWithPad() == true ) then
		setComicDialog( getMainPlayer(), "info_twister_pad");
	else
		setComicDialog( getMainPlayer(), "info_twister_mouse");
	end

return 0;
end

function On_Exit_trigger_beachStart04( )

	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );

return 0;
end

-- Respuesta a Triggers 1a Zona - Playa Final
------------------------------------------------------------------------------
function On_Enter_trigger_beachEnd( )

	-- Desactivamos el powerUp que te da el NPC
	setEntityValidByName( "Mag_PowerUp01", false );

return 0;
end

------------------------------------------ Sctiping cutScene02: conversa amb el NPC seaUrchin

function On_Enter_trigger_cutScene02( )
	if ( isFirstEnter_trigger_cutScene02 == true ) then
		StartCutScene02_first( );
		enable_enemies_scenario1_lv1( );
		isFirstEnter_trigger_cutScene02 = false;
	end
return 0;
end

----------------------------------------- Sctiping canvi de track: activa la musica del nou nivell

function On_step_platform_horitzontal_05_grass( )
	if ( isFirstStep_platform_horitzontal_05_grass == false ) then
	    
        -- Parem el ambient del mar
	    stopAmbient( "Music/ambient_ocean", false )
	    
		isFirstStep_platform_horitzontal_05_grass = true;
	end
return 0;
end


------------------------------------------ Sctiping cutScene03: es presenta el primer tauro

function On_Enter_trigger_cutScene03( )
	if ( isFirstEnter_trigger_cutScene03 == true ) then
		
		-- Invalidem el octopus per que pot donar problemes si no es mata
		hideEnemy( "Octopus05" );
		
		StartCutScene03( );
	end
return 0;
end

function On_Exit_trigger_cutScene03( )
	if ( isFirstEnter_trigger_cutScene03 == true ) then
		EnableDefaultCamera( );
		isFirstEnter_trigger_cutScene03 = false;
	end
return 0;
end

------------------------------------------ Sctiping cutScene04: el rescat del seaUrchin al llac
function On_Enter_trigger_cutScene04( )

	if ( isFirstEnter_trigger_cutScene04 == true ) then
		StartCutScene04( );
		
		-- NEW: Carles
		-- Activar transicio a tarda. Actualment dura 10 segons
		activateTransitionToLevel2();
		
	end
return 0;
end

function On_Exit_trigger_cutScene04( )
	if ( isFirstEnter_trigger_cutScene04 == true ) then
		EnableDefaultCamera( );
		isFirstEnter_trigger_cutScene04 = false;
	end
return 0;
end

------------------------------------------ Scripting pujant al nivell2 del primer escenari

function On_step_platform_horitzontal_03_grass( )
	enable_enemies_scenario1_lv2();
return 0;
end

------------------------------------------ Scripting pujant al nivell3 del primer escenari

function On_step_platform_horitzontal_11_grass( )
	enable_enemies_scenario1_lv3();
return 0;
end

------------------------------------------ Scripting pujant al nivell4 del primer escenari (1a platform)

function On_step_platform_horitzontal_18_grass( )
	enable_enemies_scenario1_lv4();
return 0;
end

------------------------------------------ Scripting pujant al nivell4 del primer escenari (2a platform)

function On_step_platform_horitzontal_16_grass( )
    if( isFirstStep_platform_horitzontal_16_grass == false ) then
	    isFirstStep_platform_horitzontal_16_grass = true;
	end
return 0;
end

function On_step_platform_horitzontal_29_grass( )
    if( isFirstStep_platform_horitzontal_29_grass == false ) then
		-- Posem el nivell de l'aigua a la posicio del llac del nivell 2
		followLake( true );
		
	    isFirstStep_platform_horitzontal_29_grass = true;
	end
return 0;
end

------------------------------------------ Sctiping del bridge d'accés a la segona fase

function On_step_platform_horitzontal_26_wood( )
  setTrackerPlayer("tracker_bridge");
return 0;
end

function On_step_platform_horitzontal_28_grass( )
  setTrackerPlayer("");
  if( isFirstStep_platform_horitzontal_28_grass == false ) then
	setInstanceBoxValidByName("elements_geo.2_lvl2", true);
	
    -- Guardem estat per si morim que estigui activat
	saveStateOfAllGameInstances();
	
	isFirstStep_platform_horitzontal_28_grass = true;
  end
return 0;
end

function On_step_platform_horitzontal_24_grass( )
  setTrackerPlayer("");
return 0;
end

function On_Enter_trigger_Bridge2D( )
	setCameraMode( 4, "", "trackerCamera_11", 4.0 );
return 0;
end

function On_Exit_trigger_Bridge2D( )
	setCameraMode( 0, "", "", 0.0 );
return 0;
end

------------------------------------------ Scripting camera inici del llac

function On_Enter_trigger_StartLake( )
	setCameraModeBlendInfo( 4, "", "trackerCamera_10", 4.0, 0.98, 0.95 );
	
	-- Establim checkPoint en aquest trigger
	setPlayerLastCheckPoint("trigger_StartLake");
	
	-- Fem desapareixer la primera plataforma
	hidePlatform("trackerPlatform_translate_11");
	
return 0;
end

function On_Exit_trigger_StartLake( )
	setCameraMode( 0, "", "", 0.0 );
return 0;
end

------------------------------------------ Scripting del cami de static01 a static02

function On_Enter_trigger_FollowPath01( )
	
	if ( isTrigger_FollowPath01_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_15", 4.0 );
		setPlayerLastCheckPoint("trigger_FollowPath01");
	end
	
return 0;
end

function On_Exit_trigger_FollowPath01( )

	if ( isTrigger_FollowPath01_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
	
return 0;
end

------------------------------------------ Scripting del cami de static02 a switch02

function On_Enter_trigger_FollowPath02( )
	
	if( isTrigger_FollowPath02_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_14", 4.0, 0.98, 0.95 );
		setPlayerLastCheckPoint("trigger_FollowPath02");
	end
	
return 0;
end

function On_Exit_trigger_FollowPath02( )

	if( isTrigger_FollowPath02_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_16", 4.0, 0.98, 0.95 );
	end
return 0;
end

------------------------------------------ Si agafa el powerUp i decideix anar a rescatar el urchin, posem aquest trigger

function On_Enter_trigger_DisablePowerUp( )

	-- Desactivem el powerUp del player
    disablePlayerPowerUp();
    activateGUIDialog( "NPC1_Dialog_PowerUp", false );
    
return 0;
end

function On_Enter_trigger_DisablePowerUp01( )

	-- Desactivem el powerUp del player
    disablePlayerPowerUp();
    activateGUIDialog( "NPC1_Dialog_PowerUp", false );
    
return 0;
end

function On_Enter_trigger_DisablePowerUp02( )

	-- Desactivem el powerUp del player
    disablePlayerPowerUp();
    activateGUIDialog( "NPC1_Dialog_PowerUp", false );
    
return 0;
end

------------------------------------------ Scripting del 1r cami del nivell2

function On_Enter_trigger_FollowPath03( )
	
	if( isTrigger_FollowPath03_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_17", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath03( )

	if( isTrigger_FollowPath03_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

------------------------------------------ Scripting del cami de static02 a al cofre (Anada)

function On_Enter_trigger_FollowAlternativePath( )

	if ( isTrigger_AlternativePath_enabled == true ) then
		if( isAlternativePathLakeVisited == false ) then
			setCameraModeBlendInfo( 4, "", "trackerCamera_12", 4.0, 0.98, 0.95 );
		end
	end
	
return 0;
end

function On_Exit_trigger_FollowAlternativePath( )
	if ( isTrigger_AlternativePath_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

------------------------------------------ Scripting del cami de static02 a al cofre (Tronada)

function On_Enter_trigger_FollowAlternativePath02( )
	
	if( isAlternativePathLakeVisited == true ) then
		setCameraMode( 4, "", "trackerCamera_13", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowAlternativePath02( )
	setCameraMode( 0, "", "", 0.0 );
	isAlternativePathLakeVisited = true;
return 0;
end

------------------------------------------ Evento: al "pisar" el lago del segundo nivel

function killPlayer( )

  local player = getMainPlayer();
  local playerPos = player:getPosition( );
  throwParticles( "water_fall_blue", playerPos, NULL );
  
  -- Pasa el player al estat de dying
  doKillPlayer();
  
return 0;
end

------------------------------------------ Evento: muerte caida al agua del primer nivel

function On_Enter_trigger_deadPlayer01( )

  local player = getMainPlayer();
  local playerPos = player:getPosition( );
  throwParticles( "water_fall_blue", playerPos, NULL );
  
  setEntityVisible( player, false );
  
  playerRestartCheckPoint();
  
return 0;
end

function On_Enter_trigger_deadPlayer02( )

  local player = getMainPlayer();
  local playerPos = player:getPosition( );
  throwParticles( "water_fall_blue", playerPos, NULL );
  
  setEntityVisible( player, false );
  
  playerRestartCheckPoint();
  
return 0;
end

function On_Enter_trigger_deadPlayer03( )

  local player = getMainPlayer();
  local playerPos = player:getPosition( );
  throwParticles( "water_fall_blue", playerPos, NULL );
  
  setEntityVisible( player, false );
  
  playerRestartCheckPoint();
  
return 0;
end

function On_Enter_trigger_deadPlayer04( )

  local player = getMainPlayer();
  setEntityVisible( player, false );
  
  playerRestartCheckPoint();
  
return 0;
end

function On_Enter_trigger_deadPlayer05( )

  local player = getMainPlayer();
  setEntityVisible( player, false );
  
  playerRestartCheckPoint();
  
return 0;
end

------------------------------------------

function On_Enter_trigger_changeLvl( )
    setCameraMode( 4, "", "trackerCamera_46", 50.0 );
return 0;
end

function On_Exit_trigger_changeLvl( )
        
    -- Activem la colisió per no poder tornar
    setEntityValidByName("platform_vertical_block_acces_Lvl1", true);
    setEntityVisibleByName("platform_vertical_block_acces_Lvl1", false);
    
return 0;
end

function On_Enter_trigger_enterLvl02( )

    -- Restablim la camera normal
    setCameraMode( 0, "", "", 50.0 );

return 0;
end
------------------------------------------ Evento: Aprofitem per borrar el primer escenari

function On_step_trackerPlatform_translate_11( )
	setInstanceBoxValidByName("InstanceBox_01", false);
	
	-- Eliminem també els sistemes de particules de la 1a cascada
	setEntityValidByName("PsEmiter_water_impact01", false);
	setEntityValidByName("PsEmiter_water_impact02", false);
	setEntityValidByName("PsEmiter_water_impact03", false);
	setEntityValidByName("PsEmiter_water_impact04", false);
	
	-- Encenem del segon nivell
	setEntityValidByName("PsEmiter_water_impact07", true);
	
	-- saveStateOfAllGameInstances();
	
return 0;
end

function On_step_trackerPlatform_static_01( )

if( isFirstStep_trackerPlatform_static_01 == false ) then

  local functionOrder;

  -- Coloca la camera fixada
  --functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_18\", 4.0 )";
  --addOrderToSequencer ( functionOrder, 0.5 );
  
  throwBattalion_staticPlatform01_first();

  isFirstStep_trackerPlatform_static_01 = true;
end

return 0;
end

------------------------------------------ Evento: matar los enemigos de la primera plataforma estatica

function On_killEnemies_staticPlatform01_first( )

	throwBattalion_staticPlatform01_second( );
	
return 0;
end

function On_killEnemies_staticPlatform01_second( )

	-- Desbloquejem el checkPoint08, que esta al staticPlatform01
	-- Aqui es guarda l'estat i els events superats
	On_Reached_checkPointStatic01();
	
	StartCutScene05();

return 0;
end

------------------------------------------ Evento: pisar la segunda plataforma estatica

function On_step_trackerPlatform_static_02( )

  if( isFirstStep_trackerPlatform_static_02 == false ) then
    setCameraMode( 4, "", "trackerCamera_16", 4.0 );
    
    -- Desactivem el powerUp del player
    disablePlayerPowerUp();
    
    throwFirstBattalion_staticPlatform02( );
    isFirstStep_trackerPlatform_static_02 = true;
  end

return 0;
end

------------------------------------------ Evento: pisar la tercera plataforma estatica (la ultima)

function On_step_trackerPlatform_static_03( )

  if( isFirstStep_trackerPlatform_static_03 == false ) then
  
    setCameraModeBlendInfo( 6, "trackerPlatform_static_03", "trackerCamera_41", 50.0, 0.0, 0.95 );
    
    local functionOrder = "setCameraModeBlendInfo( 2, \"trackerPlatform_static_03\", \"trackerCamera_41\", 50.0, 0.9, 0.95 )";
    addOrderToSequencer ( functionOrder, 0.2 );
    
    functionOrder = "checkAchivementsOfFinalGame()";
    addOrderToSequencer ( functionOrder, 0.3 );
    
    -- Sound event of final credits
    start_credits();
    
    activateFinalBonusArea();
    
    functionOrder = "BonusCoinsStage01()";
	addOrderToSequencer ( functionOrder, 5.0 );
	
    enableCreditsGUI( true );
    
    isFirstStep_trackerPlatform_static_03 = true;
  end

return 0;
end


------------------------------------------ Evento: al matar los enemigos de la segunda plataforma estatica

function On_killEnemies_staticPlatform02_first( )

  throwSecondBattalion_staticPlatform02( );

return 0;
end

function On_killEnemies_staticPlatform02_second( )

	local functionOrder = "end_StaticPlatformsBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );

	StartCutScene05_v2();
	
	-- Desbloqueig dels camins un cop acabats amb els pops
	functionOrder = "isTrigger_FollowPath02_enabled = true";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "canRescureCage(\"Cage02\", true)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "isTrigger_AlternativePath_enabled = true";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	-- Guardem l'estat
	functionOrder = "On_Reached_checkPointStatic02( )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------ Evento: al pisar las platform hacia el segundo shwitch

function On_step_trackerPlatform_hidde_02( )
	setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_step_trackerPlatform_translate_13( )
	setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_step_trackerPlatform_hidde_04( )
	setCameraMode( 0, "", "", 0.0 );
return 0;
end

------------------------------------------ Evento: activar el primer interruptor

function On_Activate_Switch01( )

	-- desactivem el comic dialog del player
	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );

	activateInput(false);

	local functionOrder;

	-- FOLLOW_TRACKER_TARGET mode
	functionOrder = "setCameraMode( 2, \"trackerPlatform_translate_01\", \"trackerCamera_01\", 20.0 )";
	addOrderToSequencer ( functionOrder, 0.3 );

	unlockPathToStaticPlatform01();

	-- Encara esta dins del trigger_StartLake
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_10\", 4.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );

	functionOrder = "activateInput(true)";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	-- Guardem l'estat de les entitats un cop activat
	functionOrder = "saveStateOfAllGameInstances( )";
	addOrderToSequencer ( functionOrder, 0.0 );

return 0;
end

------------------------------------------ Evento: activar el segundo interruptor

function On_Activate_Switch02( )

	-- hidePlants del nivell 1 del aigua
	setInstanceBoxValidByName("lakeplants1", false);
	setInstanceBoxValidByName("lakeplants2", true);
	
	setInstanceBoxValidByName("elements_plano2_lvl2", true);
	setInstanceBoxValidByName("elements_geo.2_lvl2", true);
	
	-- Amagem els powerUps del primer nivell
	setEntityValidByName("Mag_PowerUp02", false);
	setEntityValidByName("Mag_PowerUp03", false);
	setEntityValidByName("Mag_PowerUp04", false);
	
	-- Amagem els sistemes de particules del primer nivell
	setEntityValidByName("PsEmiter_water_impact05", false);
	setEntityValidByName("PsEmiter_water_impact06", false);
	desactivate_psEmiters_lightBugs_Lvl1();

	--activateInput(false);
	
	-- So de baixada de l'aigua
	playSound( "Game_situations/platformBoss_Down", Vector3(0.0, 0.0, 0.0 ) )
	playSound( "Game_situations/activate_switch", Vector3(0.0, 0.0, 0.0 ) )

	-- hidePlatforms del nivell 1
	hideLvl1Platforms( );

	-- AppearPlatforms del nivell 2
	unlockPathToSwitch03( );
	
	local functionOrder;
	
	-- Guardem l'estat de les entitats un cop activat
	functionOrder = "saveStateOfAllGameInstances( )";
	addOrderToSequencer ( functionOrder, 0.1);

return 0;
end

------------------------------------------ Evento: pisar la 1a plataforma del nivel2 del agua

function On_step_platform_horitzontal_2_05_rock( )

  if( isFirstStep_platform_horitzontal_2_05_rock == false ) then
	
	local functionOrder = "unHideEnemy(\"Shark01\")";
	addOrderToSequencer ( functionOrder, 0.3);
	
	-- reproduim el event de appearShark
    functionOrder = "shark_appearWater(getEntityPosition(\"Shark01\"), nil)";
    addOrderToSequencer ( functionOrder, 0.0 );
	
	setEntityValidByName("PsEmiter_leaf_green15", false );
	setEntityValidByName("PsEmiter_leaf_red08", false );
  
	isFirstStep_platform_horitzontal_2_05_rock = true;
  end
  
return 0;
end

------------------------------------------ Evento: Baseball gameplay

function On_killEnemies_baseballGamePlay_first( )
	
	isReached_FirstStep_BaseBallGameplay = true;
	throwSecondBattalion_baseballGamePlay( );
	
return 0;
end

function On_killEnemies_baseballGamePlay_second( )

	-- Situem la camera una mica mes alta per el boss
	-- setCameraMode( 6, "Octopus38_king", "trackerCamera_27", 10.0 );

	isReached_SecondStep_BaseBallGameplay = true;
	throwThirdBattalion_baseballGamePlay( );
	
return 0;
end

function On_killEnemies_baseballGamePlay_third( )

	isReached_BaseBallGameplay = true;
	
	local functionOrder = "end_BaseballBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );

	StartCutScene07( );
	
	-- LINE_MOV update = 1
	-- setTrackerEntity( "Octopus36_platform", "tracker_lvl2_pathWater_14", 1, 3.0 );
	-- setTrackerEntity( "Octopus37_platform", "tracker_lvl2_pathWater_15", 1, 3.0 );
	
	-- TODO(marc): De moment fem que la sortida sigui amb la fulla
	--unHidePlatform("trackerPlatform_translate_29");
	--unHidePlatform("trackerPlatform_sinTranslate_01");
	
	unHidePlatform("trackerPlatform_translate_27");
	unHidePlatform("trackerPlatform_translate_28");
	unHidePlatform("trackerPlatform_sinTranslate_02");
	
return 0;
end

------------------------------------------ Evento: pisar la primera plataforma del recorrido del nivel2 del agua

--function On_step_trackerPlatform_sinTranslate_01( )
function On_step_trackerPlatform_translate_27( )

  -- Desactivem sistema de particules
  setEntityValidByName("PsEmiter_leaf_red10", true );
  setEntityValidByName("PsEmiter_leaf_red12", true );
  setEntityValidByName("PsEmiter_leaf_red13", true );
  setEntityValidByName("PsEmiter_leaf_red18", true );
  setEntityValidByName("PsEmiter_leaf_red22", true );
  setEntityValidByName("PsEmiter_leaf_red23", true );
  
return 0;
end

------------------------------------------ Evento: pisar la ultima del primer recorrido del nivel2 del agua

function On_step_trackerPlatform_sinTranslate_02( )
--function On_step_trackerPlatform_translate_29()

  -- Desactivem sistema de particules
  setEntityValidByName("PsEmiter_leaf_red10", false );
  setEntityValidByName("PsEmiter_leaf_red12", false );
  setEntityValidByName("PsEmiter_leaf_red13", false );
  setEntityValidByName("PsEmiter_leaf_red18", false );
  setEntityValidByName("PsEmiter_leaf_red22", false );
  setEntityValidByName("PsEmiter_leaf_red23", false );
  
  -- Treiem els pops de la ultima plataforma del nivell2
  unHideEnemy( "Octopus29" );
  unHideEnemy( "Octopus30" );
  unHideEnemy( "Octopus31" );
  unHideEnemy( "Octopus32" );
  
  -- Treiem la cage04 amb el urchin
  setEntityValidByName( "Cage04", true );
  
  -- I els seaUrchin amagats
  --unHideEnemy( "SeaUrchin22_h" );
  --unHideEnemy( "SeaUrchin23_h" );
  --unHideEnemy( "SeaUrchin24_h" );
  
return 0;
end

------------------------------------------ Evento: Plataforma donde esta cage03

function On_step_platform_horitzontal_2_03_rock( )

	if( isFirstStep_platform_horitzontal_2_03_rock == false ) then 
	
		unHideEnemy("Shark02");
		
		-- reproduim el event de appearShark
        local functionOrder = "shark_appearWater(getEntityPosition(\"Shark02\"), nil)";
        addOrderToSequencer ( functionOrder, 0.0 );
			
		isFirstStep_platform_horitzontal_2_03_rock = true;
	end

return 0;
end

------------------------------------------ Evento: matar a los enemigos de la segunda plataforma del nivel 2

function On_killEnemies_lvl2_16_first ( )
	isTrigger_FollowPath04_enabled = true;
return 0;
end

------------------------------------------ Evento: player Meets unhideUrchin gameplay

function On_step_trackerPlatform_translate_04( )

	if( isFirstStep_trackerPlatform_translate_04 == false ) then
		startCutScene08( );
		isFirstStep_trackerPlatform_translate_04 = true;
	end
	
return 0;
end

------------------------------------------ Evento: player exit unhideUrchin gameplay

function On_step_trackerPlatform_translate_05( )

	-- Si conserva la bafarada la treiem en aquest punt
	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );
	
	-- desactivem la musica de batalla curta
	local functionOrder = "end_shortBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------ Evento: player defeat 4 evil Octopus

function On_killEnemies_chest04Enemies_first( )
	startCutScene09( );
return 0;
end

------------------------------------------ Evento: salir plataforma 2 del nivel 2

function On_Enter_trigger_FollowPath04( )
	
	if( isTrigger_FollowPath04_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_19", 4.0, 0.96, 0.95 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath04( )

	if( isTrigger_FollowPath04_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

---------------------------------------- Evento: salir de la plataform 3 del nivel 2

function On_Enter_trigger_FollowPath05( )
	
	if( isTrigger_FollowPath05_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_20", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath05( )

	if( isTrigger_FollowPath05_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

---------------------------------------- Evento: salir de la plataform 4 del nivel 2

function On_Enter_trigger_FollowPath06( )
	
	if( isTrigger_FollowPath06_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_21", 4.0, 0.96, 0.95 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath06( )

	if( isTrigger_FollowPath06_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

------------------------------------------ Evento: activar el tercer interruptor

function On_Activate_Switch03( )

	setInstanceBoxValidByName("elements_plano2_lvl3", true);
	setInstanceBoxValidByName("elements_geo.2_lvl3", true);
	
	setInstanceBoxValidByName("elements_plano2_lvl3_temple", true);
	
	-- Ruines de l'aigua
	setEntityValidByName("PsEmiter_leaf_red10", true );
	setEntityValidByName("PsEmiter_leaf_red12", true );
	setEntityValidByName("PsEmiter_leaf_red13", true );
	setEntityValidByName("PsEmiter_leaf_red18", true );
	setEntityValidByName("PsEmiter_leaf_red22", true );
	setEntityValidByName("PsEmiter_leaf_red23", true );
	
	-- Zona final
	setEntityValidByName("PsEmiter_leaf_red15", true );
	setEntityValidByName("PsEmiter_leaf_red16", true );
	setEntityValidByName("PsEmiter_leaf_red25", true );
	
	-- So de baixada de l'aigua
	playSound( "Game_situations/platformBoss_Down", Vector3(0.0, 0.0, 0.0 ) )
	playSound( "Game_situations/activate_switch", Vector3(0.0, 0.0, 0.0 ) )

	-- Hide currentPlatforms
	hideLvl2Platforms();

	-- Actions
	startCutScene11();

return 0;
end

------------------------------------------ Evento: pisar plataforma de la emboscada de los tiburones

function On_step_platform_horitzontal_2_08_rock( )

if( isFirstStep_platform_horitzontal_2_08_rock == false ) then
	
	--unlockPathToFinalBoss();
	
	setInstanceBoxValidByName("elements_plano2_lvl1", false);
	
	-- Desactivem els sistemes de particules no visibles
	setEntityValidByName("PsEmiter_water_impact07", false );
	setEntityValidByName("PsEmiter_water_impact11", false );
	setEntityValidByName("PsEmiter_water_impact12", false );
	setEntityValidByName("PsEmiter_water_impact13", false );
	setEntityValidByName("PsEmiter_water_impact14", false );
	setEntityValidByName("PsEmiter_water_impact15", false );
	setEntityValidByName("PsEmiter_water_impact16", false );
	
	-- Ruines de l'aigua
	setEntityValidByName("PsEmiter_leaf_red10", false );
	setEntityValidByName("PsEmiter_leaf_red12", false );
	setEntityValidByName("PsEmiter_leaf_red13", false );
	setEntityValidByName("PsEmiter_leaf_red18", false );
	setEntityValidByName("PsEmiter_leaf_red22", false );
	setEntityValidByName("PsEmiter_leaf_red23", false );
	setEntityValidByName("PsEmiter_leaf_red15", false );
	setEntityValidByName("PsEmiter_leaf_red16", false );
	setEntityValidByName("PsEmiter_leaf_red25", false );
	
	-- Eliminem els enemics presents al nivell 2 de l'aigua
	setInstanceBoxValidByName("enemiesStage2_Lvl2", false );
	
	local functionOrder = "setCameraModeBlendInfo( 4, \"\", \"trackerCamera_22\", 100.0, 0.98, 0.95 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	isFirstStep_platform_horitzontal_2_08_rock = true;
end

return 0;
end

function On_killEnemies_lastBattle_first( )

  is_killed_EnemiesInBattleSequence1 = true;
  
  local functionOrder = "Start_lastBattle_second()";
  addOrderToSequencer ( functionOrder, 0.0 );
  
return 0;
end

function On_killEnemies_lastBattle_second( )

  is_killed_EnemiesInBattleSequence2 = true;

  local functionOrder = "Start_lastBattle_third()";
  addOrderToSequencer ( functionOrder, 0.0 );
  
return 0;
end

function On_killEnemies_lastBattle_third( )

  is_killed_EnemiesInBattleSequence3 = true;
  
  local functionOrder = "Start_lastBattle_end()";
  addOrderToSequencer ( functionOrder, 0.0 );
  
return 0;
end

---------------------------------------- Evento: ir a la plataforma del finalBoss

function On_Enter_trigger_FollowPath07( )
	
	if( isTrigger_FollowPath07_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_25", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath07( )

	if( isTrigger_FollowPath07_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

---------------------------------------- Evento: Zona 2D del nivel 1, al lado de la cascada

function On_Enter_trigger_FollowPath08( )
	
	if( isTrigger_FollowPath08_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_29", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath08( )

	if( isTrigger_FollowPath08_enabled == true ) then
		setCameraMode( 0, "", "", 0.0 );
	end
return 0;
end

------------------------------------------ Evento: empezar la zona media de walkOnWaterGameplay
function On_Enter_trigger_FollowPath09( )

	start_finalBoss_stage0();
	
	--if ( isTrigger_FollowPath09_enabled == true ) then
		--setCameraMode( 4, "", "trackerCamera_30", 4.0 );
	--end
	
return 0;
end

function On_Enter_trigger_FollowPath10( )
	
	--if ( isTrigger_FollowPath10_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_32", 4.0, 0.98, 0.95 );
	--end
	
return 0;
end

function On_Exit_trigger_FollowPath10( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath12( )
	
	if ( isTrigger_FollowPath12_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_34", 4.0 );
		isTrigger_FollowPath12_enabled = false;
	end
	
return 0;
end

function On_Exit_trigger_FollowPath12( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath13( )
	
	if ( isTrigger_FollowPath13_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_35", 4.0 );
		isTrigger_FollowPath13_enabled = false;
	end
	
return 0;
end

function On_Exit_trigger_FollowPath13( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath14( )
	
	if ( isTrigger_FollowPath14_enabled == true ) then
		setCameraMode( 4, "", "trackerCamera_checkPoint03", 4.0 );
	end
	
return 0;
end

function On_Exit_trigger_FollowPath14( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

------------------------------------------ Encarar camera en la carrera sobre el agua

function On_Enter_trigger_FollowPath15( )
	
	--if ( isTrigger_FollowPath15_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_37", 4.0, 0.95, 0.95 );
		--isTrigger_FollowPath15_enabled = false;
	--end
	
return 0;
end

function On_Exit_trigger_FollowPath15( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath16( )
	
	--if ( isTrigger_FollowPath16_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_38", 4.0, 0.93, 0.94 );
		--isTrigger_FollowPath16_enabled = false;
	--end
	
return 0;
end

function On_Exit_trigger_FollowPath16( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath17( )
	
	--if ( isTrigger_FollowPath17_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_39", 4.0, 0.95, 0.95 );
		--isTrigger_FollowPath17_enabled = false;
	--end
	
return 0;
end

function On_Exit_trigger_FollowPath17( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

function On_Enter_trigger_FollowPath18( )
	
	--if ( isTrigger_FollowPath18_enabled == true ) then
		setCameraModeBlendInfo( 4, "", "trackerCamera_40", 4.0, 0.95, 0.95 );
		--isTrigger_FollowPath18_enabled = false;
	--end
	
return 0;
end

function On_Exit_trigger_FollowPath18( )
		setCameraMode( 0, "", "", 0.0 );
return 0;
end

------------------------------------------ Evento: pisar plataforma del final boss

function On_step_platform_horitzontal_2_60_rock( )

    if( isFirstStep_platform_horitzontal_2_60_rock == false ) then
      setInstanceBoxValidByName("elements_plano2_lvl3", false );
      setInstanceBoxValidByName("elements_plano2_lvl2", false );
      
      -- Desactivem els sistemes de particules del waterImpact
      setEntityValidByName("PsEmiter_water_impact08", false );
	  setEntityValidByName("PsEmiter_water_impact09", false );
	  setEntityValidByName("PsEmiter_water_impact10", false );
      
      -- programem que el shark aparegui en 2 segons
      -- local functionOrder = "validateEntityByName( \"MegaWhiteShark\" )"
      -- addOrderToSequencer ( functionOrder, 2.0 );
      
      validateEntityByName( "MegaWhiteShark" );

      -- Activem la variable "zona del final boss" per saber si estem al final
      -- del joc, o no
      activateFinalBossArea()

      --functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage1_01\", 6.0 )";
      --addOrderToSequencer ( functionOrder, 0.0 );
      
      --StartCutScene_FinalBoss_EndStage2();
      StartCutScene_FinalBoss_StartStage0();
        
      disablePlayerPowerUp();
      isFirstStep_platform_horitzontal_2_60_rock = true;
    end

return 0;
end

------------------------------------------ Evento: Pisar una de las 3 lakePlants de la fase Final del FinalBoss

function On_step_trackerPlatform_translate_20( )
	
	if( isFirstStep_trackerPlatforms_Stage3 == false ) then
	
	    activateInput(false);
		StartCutScene_FinalBoss_StartStage3();
		
		functionOrder = "setChangeFOV( false )";
	    addOrderToSequencer ( functionOrder, 0.0 );
		
		isFirstStep_trackerPlatforms_Stage3 = true;
		
        setEntityValidByName("platform_vertical_2_35", false);
		setEntityValidByName("platform_horitzontal_2_60_rock", false);
		setSpeedOfEntityTracker( "ringFinalBattle", 3.0 );
	
	end;
	
return 0;
end

function On_step_trackerPlatform_translate_21( )

	if( isFirstStep_trackerPlatforms_Stage3 == false ) then
	
	    activateInput(false);
		StartCutScene_FinalBoss_StartStage3();
		
		functionOrder = "setChangeFOV( false )";
	    addOrderToSequencer ( functionOrder, 0.0 );
		
		isFirstStep_trackerPlatforms_Stage3 = true;
		
		setEntityValidByName("platform_vertical_2_35", false);
		setEntityValidByName("platform_horitzontal_2_60_rock", false);
		setSpeedOfEntityTracker( "ringFinalBattle", 3.0 );
		
	end;
	
return 0;
end

function On_step_trackerPlatform_translate_22( )

	if( isFirstStep_trackerPlatforms_Stage3 == false ) then
	
	    activateInput(false);
		StartCutScene_FinalBoss_StartStage3();
		
		functionOrder = "setChangeFOV( false )";
	    addOrderToSequencer ( functionOrder, 0.0 );
		
		isFirstStep_trackerPlatforms_Stage3 = true;
		
		setEntityValidByName("platform_vertical_2_35", false);
		setEntityValidByName("platform_horitzontal_2_60_rock", false);
		setSpeedOfEntityTracker( "ringFinalBattle", 3.0 );
		
	end;
	
return 0;
end

----------------------------------------------------------------- Prova

function On_step_trackerPlatform_translate_26( )
	
	--setCameraModeBlendInfo( 2, "trackerCamera_Target_Stage03", "trackerCamera_43", 50.0, 0.9, 0.95 );
	
return 0;
end

------------------------------------------ Evento: activar el cuarto!? interruptor, se puede borrar
------------------------------------------ Solo se conserva para recordar como abrir la boca por scripting
function On_Activate_Switch04( )

--local instance = getInstanceManager( );
--local inst = instance:getInstanceByName( "JawShark" );
--inst:setPitch( -0.01 );

--local platformMng = getPlatformManager( );
--platformMng:setSpeedPlatform("tracker_03_Translate", 2.0);
--platformMng:setSpeedPlatform("tracker_04_Translate", 3.0);
--platformMng:setSpeedPlatform("tracker_05_Translate", 2.0);
--platformMng:setSpeedPlatform("tracker_06_Translate", 4.0);
--platformMng:setSpeedPlatform("tracker_07_Translate", 3.0);
--platformMng:setSpeedPlatform("tracker_08_Transaslate", 2.0);

return 0;
end

----------------------------------------- Trigger: dentro de la fase del finalBoss

function On_Enter_trigger_finalBossStage2_Right( )

	if( isTrigger_trigger_finalBossStage2_Right_enabled == true ) then
		local functionOrder = "setCameraModeBlendInfo( 2, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage2_Right_near\", 100.0, 0.9, 0.95 )";
		addOrderToSequencer ( functionOrder, 0.2 );
	end

return 0;
end

function On_Exit_trigger_finalBossStage2_Right( )

	if( isTrigger_trigger_finalBossStage2_Right_enabled == true ) then 
		local functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage1_01\", 20.0 )";
		addOrderToSequencer ( functionOrder, 0.5 );
	end

return 0;
end

function On_Enter_trigger_finalBossStage2_Left( )

	if( isTrigger_trigger_finalBossStage2_Left_enabled == true ) then 
		local functionOrder = "setCameraModeBlendInfo( 2, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage2_Left_near\", 100.0, 0.9, 0.95 )";
		addOrderToSequencer ( functionOrder, 0.2 );
	end

return 0;
end

function On_Exit_trigger_finalBossStage2_Left( )

	if( isTrigger_trigger_finalBossStage2_Left_enabled == true ) then 
		local functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage1_01\", 20.0 )";
		addOrderToSequencer ( functionOrder, 0.5 );
	end

return 0;
end

-------------------------------------------------------------------------- WaterFall trigger

function On_Enter_trigger_soundWaterFall( )
    playAmbient("Music/Ambient/waterFall");
return 0;
end

function On_Exit_trigger_soundWaterFall( )
    stopAmbient("Music/Ambient/waterFall", false);
return 0;
end

function On_Enter_trigger_soundWaterFall01( )
    playAmbient("Music/Ambient/waterFall");
return 0;
end

function On_Exit_trigger_soundWaterFall01( )
    stopAmbient("Music/Ambient/waterFall", false);
return 0;
end

function On_Enter_trigger_soundWaterFall02( )
    playAmbient("Music/Ambient/waterFall");
return 0;
end

function On_Exit_trigger_soundWaterFall02( )
    stopAmbient("Music/Ambient/waterFall", false);
return 0;
end

--function On_Enter_trigger_soundAmbientLake( )
    --playAmbient("Music/Ambient/lake_ambient");
--return 0;
--end

--function On_Exit_trigger_soundAmbientLake( )
    --stopAmbient("Music/Ambient/lake_ambient", false);
--return 0;
--end

--function On_Enter_trigger_soundAmbientUnderLake( )
    --playAmbient("Music/Ambient/under_lakeAmbient");
--return 0;
--end

--function On_Exit_trigger_soundAmbientUnderLake( )
    --stopAmbient("Music/Ambient/under_lakeAmbient", false);
--return 0;
--end

--------------------------------------------------------------------------