本文整理汇总了C++中logic::CEntity::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::getPosition方法的具体用法?C++ CEntity::getPosition怎么用?C++ CEntity::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logic::CEntity
的用法示例。
在下文中一共展示了CEntity::getPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: atacarJack
void atacarJack(unsigned int entityID)
{
Logic::CEntity * jack = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);
Logic::CEntity* * entidadesColision;
int numColisiones = Physics::CServer::getSingletonPtr()->detectCollisions(jack->getPosition(), 40, entidadesColision);
for(int i = 0; i < numColisiones; ++i)
{
if (!entidadesColision[i]->getTag().compare("enemy"))
{
//Entidad enemiga que atacará a Jack
Logic::CEntity * entidad = entidadesColision[i];
std::stringstream script;
script << "enemyEvent(\"AttackJack\", " << entidad->getEntityID() << ")";
ScriptManager::CServer::getSingletonPtr()->executeScript(script.str().c_str());
Logic::MAttackEntity *message = new Logic::MAttackEntity();
message->setAttack(true);
message->setEntity(jack);
entidad->emitMessage(message);
}
}
}
示例2:
std::pair<CVolumetricLightScattering::ScatteringParams, bool> CVolumetricLightScattering::getClosestLightSource(const std::list<ScatteringParams>& lightList) {
std::pair<ScatteringParams, bool> closestLightSrc;
closestLightSrc.second = false;
// Obtenemos el puntero a la entidad del jugador que en este caso es lo que nos interesa
Logic::CEntity* player = Input::CServer::getSingletonPtr()->getPlayerController()->getControllerAvatar();
if(player != NULL) {
Vector3 playerPosition = player->getPosition();
Vector2 playerPos2d(playerPosition.x, playerPosition.z);
auto it = lightList.begin();
Vector2 pos2d(it->lightPosition.x, it->lightPosition.z);
auto closestLight = it++;
float closestDist = (playerPos2d - pos2d).length();
float dist;
for(; it != lightList.end(); ++it) {
pos2d.x = it->lightPosition.x;
pos2d.y = it->lightPosition.z;
dist = (playerPos2d - pos2d).length();
if(dist < closestDist) {
closestLight = it;
closestDist = dist;
}
}
closestLightSrc.second = true;
closestLightSrc.first = *closestLight;
}
return closestLightSrc;
}
示例3: enemigosContraEnemigos
void enemigosContraEnemigos(unsigned int entityID)
{
Logic::CEntity * norah = Logic::CServer::getSingletonPtr()->getMap()->getEntityByID(entityID);
Logic::CEntity* * entidadesColision;
int numColisiones = Physics::CServer::getSingletonPtr()->detectCollisions( norah->getPosition(),80,entidadesColision);
//Iniciamos la tabla de los enemigos afectados
std::stringstream script1;
script1 << "enemigosConfundidos = {}";
ScriptManager::CServer::getSingletonPtr()->executeScript(script1.str().c_str());
for(int i = 0; i < numColisiones; ++i)
{
if ( !entidadesColision[i]->getTag().compare("enemy") ) {
//Entidad enemiga que atacara a otros enemigos
Logic::CEntity * entidad = entidadesColision[i];
float distX = entidad->getPosition().x - norah->getPosition().x;
float distZ = entidad->getPosition().z - norah->getPosition().z;
float distance2 = distX * distX + distZ * distZ;
//Solo entraran al estado los que esten a una distancia menor de 40
if (distance2 < 40 * 40) {
std::stringstream script2;
script2 << "enemyEvent(\"AttackOtherEnemies\", " << entidad->getEntityID() << ")";
ScriptManager::CServer::getSingletonPtr()->executeScript(script2.str().c_str());
//Mandamos un mensaje para que salga el icono de aturdido
Logic::MAturdido *message = new Logic::MAturdido();
message->setAturdido(true);
entidad->emitMessage(message);
}
//Atacaran hasta a los que esten a una distancia de 80
//Añadimos el enemigo a la tabla de los enemigos afectados entre los que se pueden atacar
std::stringstream script3;
script3 << "enemigosConfundidos[" << i+1 << "] = " << entidad->getEntityID();
ScriptManager::CServer::getSingletonPtr()->executeScript(script3.str().c_str());
}
}
}