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


C++ InventoryItem::getModelID方法代码示例

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


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

示例1: drawPlayerInfo

void drawPlayerInfo(PlayerController* player, GameWorld* world, GameRenderer* render)
{
	float infoTextX = render->getRenderer()->getViewport().x -
			(ui_outerMargin + ui_weaponSize + ui_infoMargin);
	float infoTextY = 0.f + ui_outerMargin;
	float iconX = render->getRenderer()->getViewport().x -
			(ui_outerMargin + ui_weaponSize);
	float iconY = ui_outerMargin;
	float wantedX = render->getRenderer()->getViewport().x -
			(ui_outerMargin);
	float wantedY = ui_outerMargin + ui_weaponSize + 3.f;

	TextRenderer::TextInfo ti;
	ti.font = 1;
	ti.size = ui_textSize;
	ti.align = TextRenderer::TextInfo::Right;

	{
		std::stringstream ss;
		ss << std::setw(2) << std::setfill('0') << world->getHour()
		   << std::setw(0) << ":"
		   << std::setw(2) << world->getMinute();

		ti.text = ss.str();
	}
	ti.baseColour = ui_shadowColour;
	ti.screenPosition = glm::vec2(infoTextX + 1.f, infoTextY+1.f);
	render->text.renderText(ti);

	ti.baseColour = ui_timeColour;
	ti.screenPosition = glm::vec2(infoTextX, infoTextY);
	render->text.renderText(ti);

	infoTextY += ui_textHeight;

	ti.text = "$" + std::to_string(world->state->playerInfo.money);
	ti.baseColour = ui_shadowColour;
	ti.screenPosition = glm::vec2(infoTextX + 1.f, infoTextY+1.f);
	render->text.renderText(ti);

	ti.baseColour = ui_moneyColour;
	ti.screenPosition = glm::vec2(infoTextX, infoTextY);
	render->text.renderText(ti);

	infoTextY += ui_textHeight;

	{
		std::stringstream ss;
		ss << "@" << std::setw(3) << std::setfill('0')
		   << (int)player->getCharacter()->getCurrentState().health;
		ti.text = ss.str();
	}
	ti.baseColour = ui_shadowColour;
	ti.screenPosition = glm::vec2(infoTextX + 1.f, infoTextY+1.f);
	render->text.renderText(ti);

	ti.baseColour = ui_healthColour;
	ti.screenPosition = glm::vec2(infoTextX, infoTextY);
	render->text.renderText(ti);

	if (player->getCharacter()->getCurrentState().armour > 0)
	{
		std::stringstream ss;
		ss << "[" << std::setw(3) << std::setfill('0')
		   << (int)player->getCharacter()->getCurrentState().armour;
		ti.text = ss.str();
		ti.baseColour = ui_shadowColour;
		ti.screenPosition = glm::vec2(infoTextX + 1.f - ui_armourOffset, infoTextY+1.f);
		render->text.renderText(ti);

		ti.baseColour = ui_armourColour;
		ti.screenPosition = glm::vec2(infoTextX - ui_armourOffset, infoTextY);
		render->text.renderText(ti);
	}

	std::string s;
	for (int i = 0; i < ui_maxWantedLevel; ++i) {
		s += "]";
	}
	ti.text = s;
	ti.baseColour = ui_shadowColour;
	ti.screenPosition = glm::vec2(wantedX + 1.f, wantedY + 1.f);
	render->text.renderText(ti);

#if 0 // Useful for debugging
	ti.text = "ABCDEFGHIJKLMANOQRTSWXYZ\nM0123456789";
	ti.size = 30;
	ti.align = TextRenderer::TextInfo::Left;
	ti.baseColour = glm::vec3(0.f, 0.f, 0.f);
	ti.screenPosition = glm::vec2(101.f, 202.f);
	render->text.renderText(ti);
	ti.baseColour = glm::vec3(1.f, 1.f, 1.f);
	ti.screenPosition = glm::vec2(100.f, 200.f);
	render->text.renderText(ti);
#endif

	InventoryItem *current = player->getCharacter()->getActiveItem();
	std::string itemTextureName = "fist";
	if (current) {
		uint16_t model = current->getModelID();
//.........这里部分代码省略.........
开发者ID:LeonardKoenig,项目名称:openrw,代码行数:101,代码来源:DrawUI.cpp

示例2: game_create_pickup

void game_create_pickup(const ScriptArguments& args)
{
	glm::vec3 pos (args[2].real, args[3].real, args[4].real);
	int id;
	int type = args[1].integer;
	
	switch(args[0].type) {
		case TInt8:
			id = (std::int8_t)args[0].integer;
			break;
		case TInt16:
			id = (std::int16_t)args[0].integer;
			break;
		default:
			RW_ERROR("Unhandled integer type");
			*args[5].globalInteger = 0;
			return;
	}
	
	if ( id < 0 )
	{
		id = -id;
		
		auto model = args.getVM()->getFile()->getModels()[id];
		std::transform(model.begin(), model.end(), model.begin(), ::tolower);
	
		id = args.getWorld()->data->findModelObject(model);
		args.getWorld()->data->loadDFF(model+".dff");
		args.getWorld()->data->loadTXD("icons.txd");
	}
	else
	{
		auto data = args.getWorld()->data->findObjectType<ObjectData>(id);
		
		if ( ! ( id >= 170 && id <= 184 ) )
		{
			args.getWorld()->data->loadDFF(data->modelName+".dff");
		}
		args.getWorld()->data->loadTXD(data->textureName+".txd");
	}
	
	PickupObject* pickup = nullptr;

	if ( id >= 170 && id <= 184 )
	{
		// Find the item for this model ID
		auto world = args.getWorld();
		InventoryItem *item = nullptr;
		for (auto i = 0; i < maxInventorySlots; ++i)
		{
			item = world->getInventoryItem(i);
			if (item->getModelID() == id) {
				auto pickuptype = (PickupObject::PickupType)type;
				pickup = new ItemPickup(args.getWorld(), pos, pickuptype, item);
				world->pickupPool.insert( pickup );
				world->allObjects.push_back(pickup);
				*args[5].globalInteger = pickup->getGameObjectID();
			}
		}
	}
	else
	{
		RW_UNIMPLEMENTED("non-item pickups");
		*args[5].globalInteger = 0;
	}
	
}
开发者ID:aap,项目名称:openrw,代码行数:67,代码来源:ObjectModule.cpp


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