Example #1
0
void NPC::ShootArrow()
{
	if (!m_flags[eAttacking])
	{
		//TODO: this isn't properly cleaned up.
		MovingObject* arrow = new MovingObject(m_graphicContext, *m_resourceManager, m_position.x, m_position.y, "Arrow");
		arrow->ConnectSlots(*m_drawSignal, *m_updateSignal);
		arrow->SetEnvList(m_environment);
		double launchAngle = Utility::CalculateTrajectory(arrow->GetPosition(), m_target->GetPosition(), arrow->GetSpeed(eCompositeSpeed), true);
		arrow->SetSpeed(eXSpeed, arrow->GetSpeed(eCompositeSpeed) * sin(launchAngle));
		arrow->SetSpeed(eYSpeed, arrow->GetSpeed(eCompositeSpeed) * cos(launchAngle));

		StartAttack();
		arrow->StartMoving(m_direction);
	}
}
Example #2
0
//TODO: fix shoot direciton and, if possible amount of objects created
void NPC::ShootMissile()
{
	if (!m_flags[eAttacking])
	{
		//TODO: this isn't properly cleaned up. Also need to add it to Level's object lists
		//All in all we need a better way to create projectiles
		MovingObject* missile = new MovingObject(m_graphicContext, *m_resourceManager, m_position.x, m_position.y, "Missile");
		missile->ConnectSlots(*m_drawSignal, *m_updateSignal);
		missile->SetEnvList(m_environment);
		missile->SetDirection(m_direction);

		if (missile->GetDirection() == eLeft) {
			missile->SetSpeed(eXSpeed, -missile->GetSpeed(eXSpeed));
		}
		StartAttack();
		missile->StartMoving(m_direction);
		m_timeSinceLastAttack = CL_System::get_time();
	}
}