void cConversationManager::Update(float lfTimestep)
{
//	if(BecomePressed( eIA_Accept )){OutputDebugString( "\n PRESSING ENTER KEY ");  }

	if (mbConversationState && mpCurrentConversationNode != NULL)
	{
	switch (mpCurrentConversationNode->meType)
		{
			case 0:
				{// Enum 0; Nodo activo de tipo eNormalTalk
					// Decrease the message time
					mfMessageTime -= lfTimestep;
					
					if ( mfMessageTime <= 0.0f || BecomePressed( eIA_Shoot ) )
					{
						//Need to continue with the next message or node
						NextMessage(0);
					}
				}
			break;
			
			case 1:
				{// Enum 1; Nodo activo de tipo eChooseTalk

					if( BecomePressed( eIA_GoUp ) && ( muiChooseOption > 0 )  )
						 muiChooseOption--;
					
					if( BecomePressed( eIA_GoDown ) && ( muiChooseOption < (mpCurrentConversationNode->mChildren.size() -1 )) )
						muiChooseOption++;
								
					if ( BecomePressed( eIA_Shoot ) )
					{
						NextMessage( muiChooseOption );
					}
				}
			break;

			default:
				{// Enum 2; Nodo activo de tipo eEndConversation
					mpCurrentConversationNode = NULL ;
				}
			break;

		}
	}else
		this->mbConversationState = false; // If we have a null mpCurrentConversationNode then it´s the end
}
//Función para actualizar el juego.
void cGame::Update( float lfTimestep )
{
	//Se actualiza la ventana:
	cWindow::Get().Update();

	// Updates application duration time
	mfAcTime += lfTimestep;

	//Se actualiza el InputManager.
	cInputManager::Get().Update(lfTimestep);

	// Checks if the effect has to be reloaded
	bool lbreloadEffect = IsPressed(eIA_ReloadEffectManager);
	if (lbreloadEffect) {
		cEffectManager::Get().Reload();
	}

	// Check if the animation keys (stop/start) are pressed
	cSkeletalMesh* lpSkeletonMesh =(cSkeletalMesh*)mSkeletalMesh.GetResource();

	static bool mbJogging = false;

	bool lbPlayJogPressed = BecomePressed(eIA_PlayJog);
	bool lbStopJogPressed = BecomePressed(eIA_StopJog);
	bool lbPlayWavePressed = BecomePressed(eIA_PlayWave);
	bool lbStopWavePressed = BecomePressed(eIA_StopWave);

	// Jog animation
	if (lbPlayJogPressed && !mbJogging){
		mbJogging = true;
		lpSkeletonMesh->PlayAnim("Jog", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Idle", 0.1f);
	}else if (lbStopJogPressed && mbJogging){
		mbJogging = false;
		lpSkeletonMesh->PlayAnim("Idle", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Jog", 0.1f);
	}

	// Wave animation
	if (lbPlayWavePressed){
		lpSkeletonMesh->PlayAnim("Wave", 1.0f, 0.1f, 0.1f);
	}else if (lbStopWavePressed){
		lpSkeletonMesh->StopAnim("Wave", 0.1f);
	}

	// Updates skeleton state
	//lpSkeletonMesh->Update(lfTimestep);
	mObject.Update(lfTimestep);
	
	//Se comprueba si hay que cerrar la aplicación, por ejemplo a causa de 
	// que el usuario haya cerrado la ventana. 
	mbFinish = mbFinish || cWindow::Get().GetCloseApplication()
		         //También se verifica si se ha producido la acción de entrada que cierra la aplicación:
				 // Pulsar la tecla ESC del teclado, el botón 1 del JoyStick o el botón central del ratón.
	             || IsPressed(eIA_CloseApplication);
	//Si es así, se cambia el booleano
	// que controla el cierre de la aplicación.

	if ( mbFinish )
	{
		return;
	}	
}
//Función para actualizar el juego.
void cGame::Update( float lfTimestep )
{ 			
	//Se actualiza la ventana:
	cWindow::Get().Update();

	// Updates application duration time
	mfAcTime += lfTimestep;

	//Se actualiza el InputManager.
	cInputManager::Get().Update(lfTimestep);

	// Checks if the effect has to be reloaded
	bool lbreloadEffect = IsPressed(eIA_ReloadEffectManager);
	if (lbreloadEffect) {
		cEffectManager::Get().Reload();
	}

	// Se actualiza niebla
	miFogStep ++;

	if (miFogStep == 1000) {
		if (mbFogIncreasing) {
			if (mfFogDensity >= 0.0005f)
				mbFogIncreasing = false;
			else
				mfFogDensity += 0.00001f;
		} else {
			if (mfFogDensity <= 0.0002f)
				mbFogIncreasing = true;
			else
				mfFogDensity -= 0.00001f;
		}

		miFogStep %= 1000;
	}
	glFogf (GL_FOG_DENSITY, mfFogDensity);

	// Recoge input teclado
	bool lbmoveFront = IsPressed( eIA_MoveFront );
	bool lbmoveBack = IsPressed( eIA_MoveBack );
	bool lbmoveLeft = IsPressed( eIA_MoveLeft );
	bool lbmoveRight = IsPressed( eIA_MoveRight );	
	bool lbswitchCamera = BecomePressed( eIA_SwitchCamera );
	bool lbswitchRasterizationMode = BecomePressed( eIA_SwitchFillLineMode );

	// Switch entre camara de juego/godmode
	if (lbswitchCamera)
		mbInGame = !mbInGame;
	// Switch entre el modo de rasterizacion solido/wireframe
	if (lbswitchRasterizationMode)
		mbRasterizationMode = !mbRasterizationMode;

	// Actualiza el flag de movimiento del personaje
	CharacterPos::Get().ResetChanged();
	// Calcula velocidad * tiempo transcurrido
	CharacterPos::Get().Update(lfTimestep);

	// Rotaciones del ratón
	float lfYaw = GetValue( eIA_MouseYaw );
	float lfPitch = GetValue( eIA_MousePitch );

	bool lbAuxCamera = IsPressed( eIA_SwitchCameraAux );

	// En modo juego, actualiza jugador
	if (mbInGame){
		mGodCamera.ResetYawPitch();
		if ( lbmoveFront && mMustang.IsAlive() ) {
			//CharacterPos::Get().MoveFront();
			//mVehicle.MoveForward(lfTimestep);
			mMustang.MoveForward(lfTimestep);
		}
		else if ( lbmoveBack && mMustang.IsAlive() ){
			//CharacterPos::Get().MoveBack();
			//mVehicle.Break(lfTimestep);
			mMustang.Break(lfTimestep);	
		}
		if ( lbmoveLeft && mMustang.IsAlive() ){
			//CharacterPos::Get().TurnLeft();
			//mVehicle.SteeringLeft(lfTimestep);
			mMustang.SteeringLeft(lfTimestep);
		}
		else if ( lbmoveRight && mMustang.IsAlive() ){
			//CharacterPos::Get().TurnRight();
			//mVehicle.SteeringRight(lfTimestep);
			mMustang.SteeringRight(lfTimestep);
		}

		// Actualizacion de cámara de juego
		// Si se pulsa la tecla de camara auxiliar se cambia la orientacion de la camara
		float lfDistance, lfYOffset;
		cVec3 lvYViewOffset;
		if (lbAuxCamera) {
			lfDistance = -4.f;	
			lfYOffset = 2.8f;
			lvYViewOffset = cVec3(0.f, 3.f, 0.f);
		} else {
			lfDistance = 8.f;
			lfYOffset = 3.3f;
			lvYViewOffset = cVec3(0.f, 0.0f, 0.f);
		}

		//cVec3 vVector = CharacterPos::Get().GetCharacterPosition() - CharacterPos::Get().GetFront() * lfDistance;

		/*m3DCamera.SetLookAt( cVec3(vVector.x,
								   vVector.y + 1.5f,
								   vVector.z),
								   CharacterPos::Get().GetCharacterPosition(), 
								   cVec3(0.0f, 1.f, 0.f) );*/
		//cVec3 vVector = mVehicle.GetChasisPos() - mVehicle.GetChasisRot() * lfDistance;
		cVec3 vVector = mMustang.GetVehicleBullet()->GetChasisPos() - mMustang.GetVehicleBullet()->GetChasisRot()  * lfDistance;

		m3DCamera.SetLookAt( cVec3(vVector.x,
								   vVector.y + lfYOffset,
								   vVector.z),
								   mMustang.GetVehicleBullet()->GetChasisPos() + lvYViewOffset, 
								   cVec3(0.0f, 1.f, 0.f) );

		bool lbFireMainWeapon = IsPressed( eIA_Fire );

		// Si no esta vivo el jugador entonces no puede disparar
		(!mMustang.IsAlive())?lbFireMainWeapon = false : lbFireMainWeapon = lbFireMainWeapon; 

		// Resetea estados de daño
		InitDamageStates();

		mMustang.Update(lfTimestep, lfYaw, lfPitch, lbAuxCamera, lbFireMainWeapon);
		mTruck.Update(lfTimestep);

	// Modo Godmode	
	} else {
		// Actualizacion camara godmode
		if ( lbmoveFront ) {
			mGodCamera.MoveFront(lfTimestep);				
		}
		else if ( lbmoveBack ){
			mGodCamera.MoveBack(lfTimestep);
		}
		if ( lbmoveLeft ){
			mGodCamera.MoveLeft(lfTimestep);
		}
		else if ( lbmoveRight ){
			mGodCamera.MoveRight(lfTimestep);
		}
		if (lfYaw || lfPitch){
			mGodCamera.MoveYawPitch(lfYaw, lfPitch, lfTimestep);
		}

		// Resetea estados de daño
		InitDamageStates();

		mMustang.Update(lfTimestep, lfYaw, lfPitch);
		mTruck.Update(lfTimestep);
	}

	//mObject.SetPosition(CharacterPos::Get().GetCharacterPosition(), CharacterPos::Get().GetYaw());

	// Actualiza personaje
	//mObject.Update(lfTimestep);

	// Update bullet physics object
	cPhysics::Get().Update(lfTimestep);

	//Se actualizan los personajes:
	cCharacterManager::Get().Update(lfTimestep);

//	((cScene *)mScene.GetResource())->Update(lfTimestep);

	// Update physic objects
	for ( unsigned int luiIndex = 0; luiIndex < 10; ++luiIndex) {
		maSphereObjects[luiIndex].Update(lfTimestep);
	}

	// Ruinas
	for ( unsigned int luiIndex = 0; luiIndex < RUINS_NUMBER; ++luiIndex) {
		maRuins[luiIndex].Update(lfTimestep);
	}

	//((cScene *)mMusExt.GetResource())->Update(lfTimestep);
	((cScene *)mMusNeu.GetResource())->Update(lfTimestep);

	// Check if the animation keys (stop/start) are pressed
	cSkeletalMesh* lpSkeletonMesh =(cSkeletalMesh*)mSkeletalMesh.GetResource();

	/*static bool mbJogging = false;

	bool lbPlayJogPressed = BecomePressed(eIA_PlayJog);
	bool lbStopJogPressed = BecomePressed(eIA_StopJog);
	bool lbPlayWavePressed = BecomePressed(eIA_PlayWave);
	bool lbStopWavePressed = BecomePressed(eIA_StopWave);

	// Jog animation
	if (lbPlayJogPressed && !mbJogging){
		mbJogging = true;
		lpSkeletonMesh->PlayAnim("Jog", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Idle", 0.1f);
	}else if (lbStopJogPressed && mbJogging){
		mbJogging = false;
		lpSkeletonMesh->PlayAnim("Idle", 1.0f, 0.1f);
		lpSkeletonMesh->StopAnim("Jog", 0.1f);
	}

	// Wave animation
	if (lbPlayWavePressed){
		lpSkeletonMesh->PlayAnim("Wave", 1.0f, 0.1f, 0.1f);
	}else if (lbStopWavePressed){
		lpSkeletonMesh->StopAnim("Wave", 0.1f);
	}*/
	
	//Se comprueba si hay que cerrar la aplicación, por ejemplo a causa de 
	// que el usuario haya cerrado la ventana. 
	mbFinish = mbFinish || cWindow::Get().GetCloseApplication()
		         //También se verifica si se ha producido la acción de entrada que cierra la aplicación:
				 // Pulsar la tecla ESC del teclado, el botón 1 del JoyStick o el botón central del ratón.
	             || IsPressed(eIA_CloseApplication);
	//Si es así, se cambia el booleano
	// que controla el cierre de la aplicación.

	if ( mbFinish )
	{
		return;
	}	
}