Beispiel #1
0
float AIChasePet::GetRank()
{
  // Find pets, get dist to each one
  float rank = -500.0f;
  float bestDist = 99999.9f;
  Characters pets;
  GetCharacters(&pets);
  for (unsigned int i = 0; i < pets.size(); i++)
  {
    OnFloorCharacter* pet = pets[i];
    if (dynamic_cast<Dino*>(pet))
    {
      continue;
    }
    if (!pet->CanBeEaten())
    {
      continue;
    }

    float distSq = (m_npc->GetPos() - pet->GetPos()).SqLen();

    static const float MAX_DIST = ROConfig()->GetFloat("dino-chase-dist"); 
    static const float MAX_DIST_SQ = MAX_DIST * MAX_DIST;

    if (distSq < bestDist && distSq < MAX_DIST_SQ)
    {
      bestDist = distSq;
      m_target = pet;
      rank = 500.0f; // ????
    }
  }
  return rank;
}
Character* CharacterManager::GetRandomCharacter()
{
	vector<Character*> apCharacters;
	GetCharacters( apCharacters );
	if( apCharacters.size() )
		return apCharacters[RandomInt(apCharacters.size())];
	else
		return GetDefaultCharacter();
}
Beispiel #3
0
void Game::checkAndSyncScore()
{
	// The function updates the scores displayed by the GUI
	std::vector<RenderableChar*> mychars = GetCharacters();
	std::string ns;
	for (int i=0; i < mychars.size(); i++ ) {
		ns = boost::lexical_cast<std::string>(i+1);
		OgreFW::getSingletonPtr()->mGUIRootWindow->getChild("Root/P" + ns + "T")->setText(mychars[i]->GetName());
		OgreFW::getSingletonPtr()->mGUIRootWindow->getChild("Root/P" + ns + "S")->setText(boost::lexical_cast<std::string>(ScoreManager::getSingletonPtr()->getScore(mychars[i]->GetName())));
	}

	// Blank out the 
	for (int i = 4 - mychars.size(); i < 4; i++) {
		ns = boost::lexical_cast<std::string>(i+1);
		OgreFW::getSingletonPtr()->mGUIRootWindow->getChild("Root/P" + ns + "T")->setText("");
		OgreFW::getSingletonPtr()->mGUIRootWindow->getChild("Root/P" + ns + "S")->setText("");
	}
}