本文整理汇总了C++中NPC::setDir方法的典型用法代码示例。如果您正苦于以下问题:C++ NPC::setDir方法的具体用法?C++ NPC::setDir怎么用?C++ NPC::setDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPC
的用法示例。
在下文中一共展示了NPC::setDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadStructure
World* StructureInterface::loadStructure(string fileName, World** external, VECTOR2 Vout)
{
ifstream fin(fileName);
if(fin.fail())
throw(GameError(gameErrorNS::FATAL_ERROR, "Error loading structure"));
int width, height;
fin>>width; fin>>height;
World* W = new World(width, height, imageLibrary);
W->getTile() = new Tile**[width];
for(int i=0; i<width; i++)
W->getTile(i) = new Tile*[height];
int x = 0, y = 0;
char c;
fin.get(c);
while(!fin.eof() && y < height)
{
if(!isspace(c))
{
assignTile(W, c, x, y, external, Vout);
x++;
if(x>=width)
{
x = 0;
y++;
}
}
fin.get(c);
}
int npcCount;
fin >> npcCount;
for (int i=0; i<npcCount; i++)
{
int ID, textLines, talkSoundID;
string sound;
char dir;
float x, y;
fin >> ID;
if(ID <= 1)
{
Image* img;
if (ID == 0) img = &imageLibrary->Character2IM;
else img = &imageLibrary->Character1IM;
fin >> textLines >> x >> y >> dir >> talkSoundID;
x += .5;y += .5;
NPC* temp = new NPC(ID, VECTOR2(x,y), img, 0);
string* text = new string[textLines];
char buffer[500];
fin.get();
for (int i=0; i<textLines; i++){
fin.getline(buffer,500);
text[i] = buffer;
if (buffer[0] == '%')
{
temp->addConditionalLine(i);
text[i] = text[i].substr(1);
}
if(text[i].find("(sword acquired)") != -1)
temp->item = "sword";
else if(text[i] == "(learned fireball attack)")
temp->item = "fireball";
}
temp->setText(text, textLines);
switch(dir){
case 'u': temp->setDir(UP); break;
case 'd': temp->setDir(DOWN); break;
case 'l': temp->setDir(LEFT); break;
case 'r': temp->setDir(RIGHT); break;
}
temp->setTalkSound(getTalkSound(talkSoundID));
W->addEntity(temp, new StationaryAI(temp));
}
else if(ID == 2)