本文整理汇总了C++中Tile::GetCurrentTileType方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::GetCurrentTileType方法的具体用法?C++ Tile::GetCurrentTileType怎么用?C++ Tile::GetCurrentTileType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::GetCurrentTileType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMapDataAsText
String Map::GetMapDataAsText() {
String mapDataAsText = "";
mapDataAsText.push_back('\n');
for (int y = m_size.y - 1; y >= 0; y--) {
for (int x = 0; x < m_size.x; x++) {
Tile* tile = GetTileAtLocation(IntVector2(x, y));
switch (tile->GetCurrentTileType()) {
case TILE_AIR:
mapDataAsText.push_back('0');
break;
case TILE_STONE:
mapDataAsText.push_back('#');
break;
case TILE_GRASS:
mapDataAsText.push_back('.');
break;
case TILE_WATER:
mapDataAsText.push_back('$');
break;
case TILE_LAVA:
mapDataAsText.push_back('x');
break;
}
}
mapDataAsText.push_back('\n');
}
//String mapData = StringUtils::ReverseString(mapDataAsText);
return mapDataAsText;
}
示例2: 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;
}
示例3: 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);
}