Exemple #1
0
bool CBurnBot::CheckCollision(IBaseObject* pObj)
{
	if(pObj == this)
		return false;

	if(!pObj->GetAlive())
		return false;

	if(!GetAlive())
		return false;

	int nType = pObj->GetID();

	bool bAvoid = nType == OBJ_SMASH || nType == OBJ_SPIDER || nType >= OBJ_VAT && nType <= OBJ_BARREL || nType == OBJ_BOSSINV || nType == OBJ_INVERSION;

	if( bAvoid )
		Utilities::CheckAvoid(this, pObj);

	if(nType >= OBJ_TRASH && nType <= OBJ_AIFIST ||  nType == OBJ_PLAYER ||  nType >= OBJ_VAT && nType <= OBJ_BARREL
		|| nType == OBJ_INVERSION || OBJ_TUNNEL)
	{
		if(SphereToSphere(GetSphere(), pObj->GetSphere()))
		{
			if(OBJ_TUNNEL)
				CollisionResponse(pObj);
			else
				AddToReactVector(pObj);
			//CollisionResponse(pObj);
			return true;
		}
	}

	return false;
}
Exemple #2
0
CGameObject* CEnemy::GetWhoIsAroundMe2(float Size)
{
   CGameObject* firstAllyInProximity = NULL;
   CGameObject* currentCloseGuy;
   CGameObject* currentObj = g_CollisionAvoidanceList;

   if (g_CollisionAvoidanceList == NULL)
      return NULL;

   const Sphere* es = GetSphere();
   Sphere MySphere = *es;

   MySphere.Radius = Size;

   do 
   {
      if (currentObj == this)
      {
         currentObj = currentObj->m_CollisionAvoidanceListNext;
         continue;
      }

      if (SphereToSphere(&MySphere, currentObj->GetSphere()))
      {
         if (firstAllyInProximity == NULL)
         {
            firstAllyInProximity = currentObj;
            currentCloseGuy  = currentObj;
         }
         else
         {
            currentCloseGuy->m_GuyNextToMe = currentObj;
            currentCloseGuy = currentObj;
         }
      }

   	currentObj = currentObj->m_CollisionAvoidanceListNext;

   } while(currentObj != NULL);

   return firstAllyInProximity;
}
Exemple #3
0
bool CSmashBot::CheckCollision(IBaseObject* pObj)
{
	if(pObj == this)
		return false;

	int nType = pObj->GetID();

	if(nType == OBJ_SMASH || nType == OBJ_SPIDER || nType == OBJ_INVERSION || nType == OBJ_TUNNEL)
	{
		if(SphereToSphere(this->GetSphere(), pObj->GetSphere()))
		{
			if( m_bIsSmashing == false || nType == OBJ_INVERSION || OBJ_TUNNEL)
			{
				AddToReactVector(pObj);
				//CollisionResponse(pObj);
				return true;
			}
		}
	}
	if(nType == OBJ_PIT)
	{
		Sphere tempSphere = GetSphere();
		tempSphere.m_Radius = 10.0f;
		if(SphereToAABB(tempSphere,((CDeathPit*)pObj)->GetAABB()))
		{
			((CDeathPit*)pObj)->SetTrapCloseTimer(2.0f);
			if(((CDeathPit*)pObj)->GetTrapIsOpen())
			{
				((CDeathPit*)pObj)->SetIsTrapOpen(false);
				((CDeathPit*)pObj)->ChangeAnimation(1);
			}
			return true;
		}
	}
	if(nType == OBJ_PLAYER)
	{
		if(SphereToSphere(this->GetSphere(), ((CPlayerObject*)pObj)->GetSphere()))
		{
			//m_bIsSmashing = true;
			AddToReactVector(pObj);
			//CollisionResponse(pObj);
			return true;
		}
	}
	if(nType == OBJ_CONVEYOR)
	{
		if(SphereToAABB(GetSphere(), ((CConveyor*)pObj)->GetAABB()))
		{
			pObj->AddToReactVector(this);
			//pObj->CollisionResponse(this);
			return true;
		}
	}
	if(nType >= OBJ_VAT && nType <= OBJ_BARREL)
	{
		if(SphereToSphere(GetSphere(),pObj->GetSphere()))
		{
			//AddToReactVector(this);
			CollisionResponse(pObj);
			return true;
		}
	}

	return false;
}
bool CExplodingBullet::CheckCollision(IBaseObject* pObj)
{
	if( !GetAlive() || !pObj->GetAlive())
		return false;

	int nType = pObj->GetID();

	switch(m_nType)
	{
	case SPECIALBULLET:
		{
			if( nType == OBJ_BULLET_ENEMY || nType > OBJ_PLAYER && nType <= OBJ_AIFIST || 
				nType >= OBJ_VAT && nType <= OBJ_BARREL || nType == OBJ_INVERSION || nType == OBJ_BOSSINV || nType == OBJ_BOSSTURRET)
			{
				std::list<IBaseObject*>::iterator iter;

				for( iter = m_lEnemies.begin(); iter != m_lEnemies.end(); ++iter )
				{
					if( (*iter) == pObj )
						return false;
				}

				if( SphereToSphere(GetSphere(), pObj->GetSphere()))
				{
					m_lEnemies.push_back(pObj);
					CollisionResponse(pObj);
					CEffect* pEffect = CGameplayState::GetInstance()->GetFX()->CreateEffect(EFFECT_SPECIALHIT,pObj->GetMatrix());
					if(pEffect)
						pEffect->SetColors((D3DXCOLOR)GetColor());
					return true;
				}
			}
		}
		break;
	case SMASHBULLET:
		{
			if( nType == OBJ_PLAYER || nType == OBJ_TRASH )
			{
				if( SphereToSphere(GetSphere(), pObj->GetSphere()))
				{
					CollisionResponse(pObj);
					return true;
				}
			}
		}
		break;
	case BARRELBULLET:
		{
			if( nType == OBJ_PLAYER || nType >= OBJ_TRASH && nType <= OBJ_STEAM)
			{
				if( SphereToSphere(GetSphere(), pObj->GetSphere()))
				{
					CollisionResponse(pObj);
					return true;
				}
			}
			else if( nType == OBJ_BARREL)
			{
				if( SphereToSphere(GetSphere(), pObj->GetSphere()))
				{
					pObj->CollisionResponse(this);
					return true;
				}
			}
		}
		break;
	case INVERSION_BULLET:
		{
			if(nType == OBJ_PLAYER)
			{
				if(SphereToSphere(GetSphere(), pObj->GetSphere()))
				{
					CollisionResponse(pObj);
					return true;
				}
			}
		}
	}
	return false;
}