当前位置: 首页>>代码示例>>C++>>正文


C++ Tiles::get方法代码示例

本文整理汇总了C++中Tiles::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Tiles::get方法的具体用法?C++ Tiles::get怎么用?C++ Tiles::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tiles的用法示例。


在下文中一共展示了Tiles::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: finish

void UpgradeWork::finish(Island* island, const Event& e) {
	Tiles* tiles = island->getTiles();
	tiles->clear_state(e.tile_x,e.tile_y,TS_ACTIVE);
	Tile& t = tiles->get(e.tile_x, e.tile_y);
	++t.level;
	// remove old regular work
	island->removeWork(PT_REGULAR,e.tile_x, e.tile_y);
	// create new
	island->calculateMaxResources();
	Resources tmp;
	if (gContext->price_registry.get(PT_REGULAR, 0, t.building_id, t.level, &tmp)) {
		island->createWork(PT_REGULAR, e.tile_x, e.tile_y, t.building_id, t.level);
	}
}
开发者ID:amecky,项目名称:space,代码行数:14,代码来源:UpgradeWork.cpp

示例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;
	}
开发者ID:amecky,项目名称:space,代码行数:40,代码来源:vis.cpp


注:本文中的Tiles::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。