/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update():	This function updates the actions that are expected to be observed in this state.
//
// Returns:		void
//
// Mod. Name: Josh Morgan
// Mod. Date:8/9/12
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CSlimeMonsterIdleAI::Update(float _fDT)
{
	if(m_fIdleTimer < IDLE_TIME)
	{
		//we stay idle this long to space out attacks
		m_fIdleTimer += _fDT;
#if _ANIMATIONS
		if(m_pAnimComponent)
		{
			m_pAnimComponent->GetAnimStateMachine()->ChangeState(SlimeMonsterIdleState::GetState());
		}
#endif
	}
	else
	{
		if(CheckLoS())
		{
			//if the player is in line of sight of the slime monster attack
			m_pParentAIcmp->SwitchAI(AI_ATTACK);
			m_bIdleSound = false;
		}
		else
		{
			//can't see the player. time to hide.
			m_pParentAIcmp->SwitchAI(AI_HIDE);
			m_bIdleSound = false;
		}

		m_fIdleTimer = 0.0f;
	}

	if(!m_bIdleSound && m_fIdleTimer >= IDLE_TIME*0.5f)
	{
		if(m_pSoundCmp)
		{
			m_pSoundCmp->PlaySound(AK::EVENTS::PLAY_DLG_SLIMEMONSTER_IDLE);
		}
		m_bIdleSound = true;
	}
}
Ejemplo n.º 2
0
void AAgent::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	
	SensingComp->RequestStimuliListenerUpdate();
	
	if (bPlayerSeen)  
	{
		// Check our LoS to the player and act accordingly when broken.
		CheckLoS();
		// Inside the bPlayerSeen check because there is no point in the agent
		// changing weapon if they cannot see the weapon
		FVector AgentPos = GetActorLocation();
		FVector PlayerPos = FVector(0.0f, 0.0f, 0.0f);
		AAgentController* Controller = Cast<AAgentController>(GetController());
		if (Controller != NULL)
			PlayerPos = Controller->GetFocalPoint();
		// Get the vector from the agent to the player
		FVector AgentToPlayer = PlayerPos - AgentPos;
		// Pass the distance between the agent and the player (magnitude of the vector)
		// Continiously make choices on which weapon to select
		SelectWeapon(AgentToPlayer.Size());
	}
}