本文整理汇总了C++中Guard::addObjective方法的典型用法代码示例。如果您正苦于以下问题:C++ Guard::addObjective方法的具体用法?C++ Guard::addObjective怎么用?C++ Guard::addObjective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guard
的用法示例。
在下文中一共展示了Guard::addObjective方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
//.........这里部分代码省略.........
QPolygonF myPolygon;
myPolygon << QPointF(-5, 0) << QPointF(0, 5)
<< QPointF(5, 0) << QPointF(0, -5)
<< QPointF(-5, 0);
board[j][i]->setPolygon(myPolygon);
board[j][i]->setZValue(0);
board[j][i]->setBrush(Qt::blue);
goals.append(board[j][i]);
}
board[j][i]->occupant = NULL;
this->addItem(board[j][i]);
}
}
/*for(int i = 0; i < 16; ++i){
this->addLine((float)(i * 20),0.0,(float)(i * 20),300.0,QPen(QColor(Qt::gray)));
this->addLine(0.0,(float)(i * 20),300.0,(float)(i * 20),QPen(QColor(Qt::gray)));
}*/
// --------------------------------------
QString fileName = "test2.glbt.xml";
QFile file(fileName);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug("Could not open behavior tree file");
return;
}
QByteArray byteArray = file.readAll();
QString fileContents(byteArray.data());
file.close();
/* QString logFilename = "log.txt";
logFile = new QFile(logFilename);
if(!logFile->open(QIODevice::Append | QIODevice::Text)){
qDebug("Could not open file");
return;
}
QTextStream out(logFile);
out << ";Board;Killtime;Avg Killtime;Interest;Challenge;Behavior Div;Spatial Div;Max Deviation;Standard Deviation;\n";//*/
//QByteArray byteArray = logFile.readAll();
// QString fileContents(byteArray.data());
//file.close();
btBrain *brain = new btBrain(fileContents);
//this->setBackgroundBrush(QBrush(QColor(Qt::black)));
/* ss = new ScenarioSet();
Scenario *s1 = new Scenario();
ss->addScenario(s1);*/
marker = new Player(this,QPoint(8,12));//new GameItem(this);
connect(marker, SIGNAL(pacmanLost()), this, SLOT(resetAfterLost()));
connect(marker, SIGNAL(pacmanWon()), this, SLOT(resetAfterWon()));
marker->setBrush(Qt::magenta);
Enemy *player = new Enemy(marker,brain->getBehaviorTree(2));
player->thename = "mr. anderson";
Runner* playerRunner = new Runner(player);
connect(playerRunner, SIGNAL(finished()), this, SLOT(resetGame()));
runners.append(playerRunner);//*/
//int trees[3] = {6,7,9}; // pinky
//int trees[3] = {7,7,9}; // clyde
//int trees[3] = {9,7,9}; // Blinky
//int trees[3] = {0,7,9}; // Pure Random*/
//int trees[1] = {0};
int trees[1] = {1};
ColorGen colors(0,255,30);
for (int i = 0; i < this->numberOfEnemies(); i++)
{
Guard* agent = new Guard(this,QPoint(0,0));
Enemy *enemy = new Enemy(agent,brain->getBehaviorTree(trees[i]));
agent->setBrush(QBrush(colors.nextColor()));
Runner* runner = new Runner(enemy);
connect(runner, SIGNAL(finished()), this, SLOT(resetGame()));
runners.append(runner);
enemy->thename = "mr. smith " + QVariant(i).toString();
agent->addObjective(marker);
//connect(agent, SIGNAL(enteredNewCell(int,int)), s1, SLOT(visit(int,int)));
marker->addObjective(agent);
}//*/
foreach(GameItem* goal,goals){
marker->addGoal(goal);
}