Esempio n. 1
0
/**
* CAIManager::CAIManager
* @date Modified March 30, 2006
*/
CAIManager::CAIManager(void) : m_bUpdateGoalLinks(true), m_bSkipCurrentObjective(false)
{
	// go to the object manager and get the players and create nodes for them
	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();
	CObjectManager::ObjectList loPlayers;
	poObjectManager->getObjects(OBJ_PLAYER, &loPlayers);

	CObjectManager::ObjectList::iterator oPlayerIter = loPlayers.begin();

	while (oPlayerIter != loPlayers.end())
	{
		CAINode* newNode = new CAINode;
		newNode->setPosition(ACTOR_PTR(oPlayerIter)->getBV().centerPt);
		newNode->setRadius(1.0f);
		m_loGoals.push_back(newNode);
		oPlayerIter++;
	}

	m_oLeaderTimer.setInterval(0.1f);
	m_oObjectiveTimer.setInterval(0.15f);
	m_poCurrentObjective = NULL;

	m_poObjectiveEmitter = (CParticleEmitter*)CObjectManager::getInstance().createObject(OBJ_PARTICLE_EMITTER);
	m_poObjectiveEmitter->setSystem((CParticleSystem*)CResourceManager::getInstance().loadResource(RES_PARTICLEEMITTER, "objective.xml"));
}
Esempio n. 2
0
/**
* CAIManager::update
* @date Modified April 26, 2006
*/
void CAIManager::update(void)
{
	// go to the object manager and get the players and update the nodes corresponding to them
	CObjectManager* poObjectManager = CObjectManager::getInstancePtr();
	CObjectManager::ObjectList loPlayers;
	poObjectManager->getObjects(OBJ_PLAYER, &loPlayers);
	CObjectManager::ObjectList::iterator oPlayerIter = loPlayers.begin();

	// now that we have the players, check to see it there are any cluckin bombs to add as goals
	CObjectManager::ObjectList loBombs;
	poObjectManager->getObjects(OBJ_WEAPON_BIGCLUCKINGBOMB, &loBombs);
	CObjectManager::ObjectList::iterator oBombIter = loBombs.begin();
	while (oBombIter != loBombs.end())
	{
		loPlayers.push_back((*oBombIter));
		oBombIter++;
	}

	std::list<CAINode*>::iterator oNodeIter = m_loGoals.begin();

	bool bUpdateGoalLinks = false;
	if (m_bUpdateGoalLinks)
	{
		bUpdateGoalLinks = true;
		m_bUpdateGoalLinks = false;
	}

	while (oNodeIter != m_loGoals.end() && oPlayerIter != loPlayers.end())
	{
		// to cover the case of a big cluckin bomb, keep the goal node off the ground
		(*oNodeIter)->setPosition(D3DXVECTOR3(ACTOR_PTR(oPlayerIter)->getBV().centerPt.x, ((CPlayer*)loPlayers.front())->getBV().centerPt.y, ACTOR_PTR(oPlayerIter)->getBV().centerPt.z));

		if (bUpdateGoalLinks)
		{
			unlinkNode(*oNodeIter);
			linkNode(*oNodeIter);
		}			

		oNodeIter++;
		oPlayerIter++;
	}

	// cases where a player quits
	if (oNodeIter != m_loGoals.end())
	{
		while (oNodeIter != m_loGoals.end())
		{
			unlinkNode(*oNodeIter);
			delete *oNodeIter;
			oNodeIter = m_loGoals.erase(oNodeIter);
		}
	}
	
	// case where a player joins
	if (oPlayerIter != loPlayers.end())
	{
		while (oPlayerIter != loPlayers.end())
		{
			CAINode* newNode = new CAINode;
			// to cover the case of a big cluckin bomb, keep the goal node off the ground
			newNode->setPosition(D3DXVECTOR3(ACTOR_PTR(oPlayerIter)->getBV().centerPt.x, ((CPlayer*)loPlayers.front())->getBV().centerPt.y, ACTOR_PTR(oPlayerIter)->getBV().centerPt.z));
			newNode->setRadius(1.0f);
			m_loGoals.push_back(newNode);
			linkNode(newNode);
			oPlayerIter++;
		}
	}

	updateGroupLeaders();
	updateSpawnTriggers();
	updateCurrentObjective();

	// make sure this gets reset every time or the objectives will skip to gameover
	m_bSkipCurrentObjective = false;
}