本文整理汇总了C++中Cube::getInfection方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::getInfection方法的具体用法?C++ Cube::getInfection怎么用?C++ Cube::getInfection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::getInfection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateInfectionState
int Map::updateInfectionState( void )
{
int counter = 0;
for( int y = 0; y < levels; y++ )
for( int z = 0; z < height; z++ )
for( int x = 0; x < width; x++ )
{
int infection = getInfection(x, y, z);
if(infection < MAX_INFECTION)
continue;
Cube *cube;
for( int i = -1; i < 2; i++ )
for( int j = -1; j < 2; j++ )
for( int k = -1; k < 2; k++ )
{
if(!i &&!j && !k)
continue;
cube = getCube(x+k, y+i, z+j);
if(cube && !cube->isTransparent())
{
int inf = cube->getInfection();
counter += cube->incInfection() - inf;
}
}
getCube(x,y,z)->setInfection(0);
getCube(x,y,z)->setTransparent(true);
}
return counter;
}
示例2: makePlan
unsigned char HealAgent::makePlan(Map *map, QList<CubeBasic *> enemy, int coord[])
{
qDebug() << "Heal step!";
Cube *cube;
unsigned char plan = 0;
for( int y = coord[1]-1; y < coord[1]+2; y++ )
for( int z = coord[2]-1; z < coord[2]+2; z++ )
for( int x = coord[0]-1; x < coord[0]+2; x++ )
{
cube = map->getCube(x,y,z);
if(!cube)
continue;
if(x == coord[0] && y == coord[1] && z == coord[2])
continue;
if(x > coord[0])
plan = plan | (1 << 4);
else if(x < coord[0])
plan = plan | (1 << 5);
if(y > coord[1])
plan = plan | (1 << 2);
else if(y < coord[1])
plan = plan | (1 << 3);
if(z > coord[2])
plan = plan | (1 << 6);
else if(z < coord[2])
plan = plan | (1 << 7);
if(isEnemy(map, enemy, x,y,z))
{
plan = plan | 3;
return plan;
}
if(cube->getInfection())
{
plan = plan | 1;
return plan;
}
plan = 0;
}
int i, j, k;
cube = NULL;
while(!cube)
{
i = qrand() % 3 - 1;
j = qrand() % 3 - 1;
k = qrand() % 3 - 1;
if(i > 1)
i = 1;
if(j > 1)
j = 1;
if(k > 1)
k = 1;
if(!i && !j && !k)
continue;
cube = map->getCube(coord[0] + i, coord[1] + j, coord[2] + k);
qDebug() << "CUBE: " << cube << coord[0] + i << coord[1] + j << coord[2] + k;
if(!cube)
continue;
if(!cube->isTransparent())
cube = NULL;
}
plan = 0;
if(k == -1)
plan = plan | (1 << 7);
if(k == 1)
plan = plan | (1 << 6);
if(i == -1)
plan = plan | (1 << 5);
if(i == 1)
plan = plan | (1 << 4);
if(j == -1)
plan = plan | (1 << 3);
if(j == 1)
plan = plan | (1 << 2);
setPlan(plan);
return plan;
}