示例#1
0
void GameMechanic::UpdateShoot(float dt)
{
	vector<Bullet*>::iterator it;
	for(it = mBullets.begin(); it != mBullets.end(); ++it)
	{
		Bullet* bullet = *it;
		bullet->Update(dt);
		
		vector<Bot*>::iterator botIt;
		for (botIt = mBots.begin(); botIt != mBots.end(); ++botIt )
		{
			Bot* bot = *botIt;
			if(xEntityDistance(bot->GetHandle(), bullet->GetHandle()) < 50.f)
			{
				bot->DealDamage(mPlayer->GetDamage());
				if(bot->GetHealth() == 0)
					RemoveBot(botIt);
				RemoveBullet(it);
				return;
			}
		}

		//todo: investigate how to remove group of objects from collection
		float distance = xEntityDistance(bullet->GetHandle(), bullet->GetStartPositionPivot());
		if( distance > 1000.f)
		{
			RemoveBullet(it);
			return;
		}
	}
}