void RPG_Pickup::CheckCharacterContact() { VArray<RPG_Character*> const& characters = RPG_GameManager::s_instance.GetCharacters(); hkvVec3 const& currentPosition = GetPosition(); for(int index = 0; index < characters.GetSize(); ++index) { RPG_Character* character = characters.GetAt(index); // only target players if(!character->IsOfType(V_RUNTIME_CLASS(RPG_PlayerCharacter))) { continue; } hkvVec3 const& targetPosition = character->GetPosition(); float currentRangeSquared = (currentPosition - targetPosition).getLengthSquared(); if(currentRangeSquared <= m_pickupRadius * m_pickupRadius) { // call OnPickup for subclasses OnPickup(character); // play the pickup effect CreateEffect(PKFX_Pickup, GetPosition(), GetOrientation()); // setup this object for deletion DisposeObject(); } } }
void Pickup::OnCollision(Entity *e) { if(e == game.player) { OnPickup(); alive = false; PlaySample((SAMPLE *) game.GetData("snd_pickup")); } }
void CPickupBase::Update( int backGroundX, int backGroundY ) { m_entity->SetPosition( (m_entity->GetPosition().x()) - backGroundX, (m_entity->GetPosition().y()) - backGroundY ); const float xDiff = m_entity->GetPosition().x() - 132.0f; const float yDiff = m_entity->GetPosition().y() - 96.0f; if (CSOGI::GetInstance().IsAlmost(sqrt((xDiff * xDiff) + (yDiff * yDiff)), 0.0f, 32.0f)) { OnPickup(); } }