本文整理汇总了C++中Tile::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::IsValid方法的具体用法?C++ Tile::IsValid怎么用?C++ Tile::IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::IsValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindRandomValidLocationToSpawn
IntVector2 Map::FindRandomValidLocationToSpawn() {
IntVector2 position;
bool foundALocation = false;
int indicesToConsider = m_tiles.size();
int numTimesRan = 0;
while (!foundALocation) {
int ind = RandInt(0, indicesToConsider - 1);
Tile* currTile = GetTileAtIndex(ind);
if (nullptr != currTile && currTile->IsValid() && currTile->GetCurrentTileType() != TILE_WATER && currTile->GetCurrentTileType() != TILE_LAVA) {
position = currTile->GetLocation();
foundALocation = true;
}
if (numTimesRan > 10000) {
DebuggerPrintf("ERROR: Find Random Valid Location running too long.");
return IntVector2(0, 0);
}
numTimesRan++;
}
return position;
}
示例2: GetLocationWithOpeningOnEitherSide
IntVector2 Map::GetLocationWithOpeningOnEitherSide() {
std::vector<Tile*> allStoneTilesOnMap;
for (int x = 0; x < m_size.x; x++) {
for (int y = 0; y < m_size.y; y++) {
IntVector2 loc = IntVector2(x, y);
Tile* currTile = GetTileAtLocation(loc);
if (currTile->GetCurrentTileType() == TILE_STONE) {
allStoneTilesOnMap.push_back(currTile);
}
}
}
int numTimesRan = 0;
bool b = true;
while (b) {
int which = RandIntZeroToSize(allStoneTilesOnMap.size());
Tile*& currTile = allStoneTilesOnMap[which];
IntVector2 loc = currTile->GetLocation();
Tile* tileToLeft = GetTileAtLocation(loc + WEST);
Tile* tileToRight = GetTileAtLocation(loc + EAST);
Tile* tileToUp = GetTileAtLocation(loc + NORTH);
Tile* tileToDown = GetTileAtLocation(loc + SOUTH);
if (tileToLeft && tileToRight && tileToLeft->IsValid() && tileToRight->IsValid()) {
return loc;
}
else if (tileToUp && tileToDown && tileToUp->IsValid() && tileToDown->IsValid()) {
return loc;
}
if (numTimesRan > 10000) {
DebuggerPrintf("ERROR: Find Random Valid Location running too long.");
return IntVector2(0, 0);
}
numTimesRan++;
}
return IntVector2(0, 0);
}