本文整理汇总了C++中Tiles::getBuildingID方法的典型用法代码示例。如果您正苦于以下问题:C++ Tiles::getBuildingID方法的具体用法?C++ Tiles::getBuildingID怎么用?C++ Tiles::getBuildingID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tiles
的用法示例。
在下文中一共展示了Tiles::getBuildingID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
// ------------------------------------------------------
// StartWork
// ------------------------------------------------------
bool UpgradeWork::start(Island* island, const TextLine& line) {
int x = line.get_int(1);
int y = line.get_int(2);
Tiles* tiles = island->getTiles();
int idx = x + y * tiles->width;
if ( tiles->getBuildingID(idx) == -1 ) {
gContext->messages.report_error("There is no building at %d %d",x,y);
return false;
}
// FIXME: check if there is only a regular work item
if ( tiles->isActive(idx)) {
gContext->messages.report_error("The building is active - upgrade is not available");
return false;
}
if (island->checkRequirements(tiles->getBuildingID(idx), tiles->getLevel(idx) + 1)) {
tiles->set_state(x,y,TS_ACTIVE);
island->createWork(PT_UPGRADE,x,y,tiles->getBuildingID(idx),tiles->getLevel(idx)+1);
return true;
}
return false;
}
示例2: describe_building
// ------------------------------------------------------
// describe building
// ------------------------------------------------------
bool describe_building(Island* island,int x, int y) {
Tiles* tiles = island->getTiles();
int idx = x + y * tiles->width;
if (tiles->getBuildingID(idx) == -1) {
gContext->messages.report_error("There is no building at %d %d", x, y);
return false;
}
const Tile& t = tiles->get(x, y);
printf("Building: %s\n", gContext->building_definitions.getName(t.building_id));
printf(" Level: %d\n", t.level);
Resources tmp;
if (gContext->price_registry.get(PT_REGULAR, 2, t.building_id, t.level, &tmp)) {
printf("Regular income:\n");
printf("Duration: %d\n", gContext->price_registry.getDuration(PT_REGULAR, t.building_id, t.level));
res::show_resources(gContext->resource_registry, tmp, false);
}
printf("Available work:\n");
for (int i = 1; i <= t.level; ++i) {
if (gContext->price_registry.get(PT_WORK, 0, t.building_id, i, &tmp)) {
printf(" Level %d\n", i);
printf("Duration: %d\n", gContext->price_registry.getDuration(PT_WORK, t.building_id, i));
printf("Costs:\n");
res::show_resources(gContext->resource_registry, tmp, false);
}
if (gContext->price_registry.get(PT_WORK, 1, t.building_id, i, &tmp)) {
printf("Income:\n");
Resources collect;
if (gContext->price_registry.get(PT_WORK, 2, t.building_id, i, &collect)) {
tmp.add(collect);
}
res::show_resources(gContext->resource_registry, tmp, false);
}
}
// FIXME: list start options
return true;
}
示例3: print_map
void print_map(Island* island, int centerX, int centerY, int size) {
Tiles* tiles = island->getTiles();
int xmin = centerX - size;
int xmax = centerX + size;
int ymin = centerY - size;
int ymax = centerY + size;
if (xmin < 0) {
xmin = 0;
xmax = 2 * size;
}
if (xmax >= tiles->width) {
xmin = tiles->width - 2 * size;
xmax = tiles->width;
}
if (ymin < 0) {
ymin = 0;
ymax = 2 * size;
}
if (ymax >= tiles->height) {
ymin = tiles->height - 2 * size;
ymax = tiles->height;
}
for ( int y = ymax - 1; y >= ymin; --y ) {
printf("%2d | ", y);
for ( int x = xmin; x < xmax; ++x ) {
int idx = x + y * tiles->width;
if ( tiles->has_state(x,y,TS_LOCKED)) {
printf("?? ");
}
else if ( tiles->has_state(x,y,TS_UNDEFINED)) {
printf(" ");
}
else {
if ( tiles->getBuildingID(idx) != -1 ) {
printf("%s", gContext->building_definitions.getSign(tiles->getBuildingID(idx)));
if ( tiles->isActive(idx)) {
printf("# ");
}
else if ( tiles->has_state(x,y,TS_COLLECTABLE)) {
printf("* ");
}
else {
printf(" ");
}
}
else if ( tiles->_tiles[idx].ref_id != -1 ) {
printf("xx ");
}
else {
printf("- ");
}
}
}
printf("\n");
}
printf(" -----------------------------------------------------------------\n");
printf(" ");
for (int i = xmin; i < xmax; ++i) {
printf("%2d ", i);
}
printf("\n");
}