本文整理汇总了C++中Npc::setMasterPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Npc::setMasterPosition方法的具体用法?C++ Npc::setMasterPosition怎么用?C++ Npc::setMasterPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npc
的用法示例。
在下文中一共展示了Npc::setMasterPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseSpawnNode
//.........这里部分代码省略.........
centerPos.y = intValue;
if(!readXMLInteger(p, "centerz", intValue))
return false;
centerPos.z = intValue;
}
else
{
IntegerVec posVec = vectorAtoi(explodeString(strValue, ","));
if(posVec.size() < 3)
return false;
centerPos = Position(posVec[0], posVec[1], posVec[2]);
}
if(!readXMLInteger(p, "radius", intValue))
return false;
int32_t radius = intValue;
Spawn* spawn = new Spawn(centerPos, radius);
if(checkDuplicate)
{
for(SpawnList::iterator it = spawnList.begin(); it != spawnList.end(); ++it)
{
if((*it)->getPosition() == centerPos)
delete *it;
}
}
spawnList.push_back(spawn);
for(xmlNodePtr tmpNode = p->children; tmpNode; tmpNode = tmpNode->next)
{
if(!xmlStrcmp(tmpNode->name, (const xmlChar*)"monster"))
{
if(!readXMLString(tmpNode, "name", strValue))
continue;
std::string name = strValue;
int32_t interval = MINSPAWN_INTERVAL / 1000;
if(readXMLInteger(tmpNode, "spawntime", intValue) || readXMLInteger(tmpNode, "interval", intValue))
{
if(intValue <= interval)
{
std::clog << "[Warning - Spawns::loadFromXml] " << name << " " << centerPos << " spawntime cannot"
<< " be less than " << interval << " seconds." << std::endl;
continue;
}
interval = intValue;
}
interval *= 1000;
Position placePos = centerPos;
if(readXMLInteger(tmpNode, "x", intValue))
placePos.x += intValue;
if(readXMLInteger(tmpNode, "y", intValue))
placePos.y += intValue;
if(readXMLInteger(tmpNode, "z", intValue))
placePos.z /*+*/= intValue;
Direction direction = NORTH;
if(readXMLInteger(tmpNode, "direction", intValue) && direction >= EAST && direction <= WEST)
direction = (Direction)intValue;
spawn->addMonster(name, placePos, direction, interval);
}
else if(!xmlStrcmp(tmpNode->name, (const xmlChar*)"npc"))
{
if(!readXMLString(tmpNode, "name", strValue))
continue;
std::string name = strValue;
Position placePos = centerPos;
if(readXMLInteger(tmpNode, "x", intValue))
placePos.x += intValue;
if(readXMLInteger(tmpNode, "y", intValue))
placePos.y += intValue;
if(readXMLInteger(tmpNode, "z", intValue))
placePos.z /*+*/= intValue;
Direction direction = NORTH;
if(readXMLInteger(tmpNode, "direction", intValue) && direction >= EAST && direction <= WEST)
direction = (Direction)intValue;
Npc* npc = Npc::createNpc(name);
if(!npc)
continue;
npc->setMasterPosition(placePos, radius);
npc->setDirection(direction);
npcList.push_back(npc);
}
}
return true;
}