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


C++ Outfit类代码示例

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


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

示例1: UpdateRequirements

void OutfitInfoDisplay::UpdateRequirements(const Outfit &outfit)
{
	requirementLabels.clear();
	requirementValues.clear();
	requirementsHeight = 20;
	
	requirementLabels.push_back("cost:");
	requirementValues.push_back(Format::Number(outfit.Cost()));
	requirementsHeight += 20;
	
	static const string names[] = {
		"outfit space needed:", "outfit space",
		"weapon capacity needed:", "weapon capacity",
		"engine capacity needed:", "engine capacity",
		"gun ports needed:", "gun ports",
		"turret mounts needed:", "turret mounts"
	};
	static const int NAMES =  sizeof(names) / sizeof(names[0]);
	for(int i = 0; i + 1 < NAMES; i += 2)
		if(outfit.Get(names[i + 1]))
		{
			requirementLabels.push_back(string());
			requirementValues.push_back(string());
			requirementsHeight += 10;
		
			requirementLabels.push_back(names[i]);
			requirementValues.push_back(Format::Number(-outfit.Get(names[i + 1])));
			requirementsHeight += 20;
		}
}
开发者ID:YuriGobbi,项目名称:endless-sky,代码行数:30,代码来源:OutfitInfoDisplay.cpp

示例2: UpdateRequirements

void OutfitInfoDisplay::UpdateRequirements(const Outfit &outfit, const PlayerInfo &player, bool canSell)
{
	requirementLabels.clear();
	requirementValues.clear();
	requirementsHeight = 20;
	
	int day = player.GetDate().DaysSinceEpoch();
	int64_t cost = outfit.Cost();
	int64_t buyValue = player.StockDepreciation().Value(&outfit, day);
	int64_t sellValue = player.FleetDepreciation().Value(&outfit, day);
	
	if(buyValue == cost)
		requirementLabels.push_back("cost:");
	else
	{
		ostringstream out;
		out << "cost (" << (100 * buyValue) / cost << "%):";
		requirementLabels.push_back(out.str());
	}
	requirementValues.push_back(Format::Number(buyValue));
	requirementsHeight += 20;
	
	if(canSell && sellValue != buyValue)
	{
		if(sellValue == cost)
			requirementLabels.push_back("sells for:");
		else
		{
			ostringstream out;
			out << "sells for (" << (100 * sellValue) / cost << "%):";
			requirementLabels.push_back(out.str());
		}
		requirementValues.push_back(Format::Number(sellValue));
		requirementsHeight += 20;
	}
	
	static const string names[] = {
		"outfit space needed:", "outfit space",
		"weapon capacity needed:", "weapon capacity",
		"engine capacity needed:", "engine capacity",
		"gun ports needed:", "gun ports",
		"turret mounts needed:", "turret mounts"
	};
	static const int NAMES =  sizeof(names) / sizeof(names[0]);
	for(int i = 0; i + 1 < NAMES; i += 2)
		if(outfit.Get(names[i + 1]))
		{
			requirementLabels.push_back(string());
			requirementValues.push_back(string());
			requirementsHeight += 10;
		
			requirementLabels.push_back(names[i]);
			requirementValues.push_back(Format::Number(-outfit.Get(names[i + 1])));
			requirementsHeight += 20;
		}
}
开发者ID:TeoTwawki,项目名称:endless-sky,代码行数:56,代码来源:OutfitInfoDisplay.cpp

示例3: push_luavalue

int push_luavalue(const Outfit& outfit)
{
    g_lua.createTable(0, 8);
    g_lua.pushInteger(outfit.getId());
    g_lua.setField("type");
    g_lua.pushInteger(outfit.getAuxId());
    g_lua.setField("auxType");
    if(g_game.getFeature(Otc::GamePlayerAddons)) {
        g_lua.pushInteger(outfit.getAddons());
        g_lua.setField("addons");
    }
    g_lua.pushInteger(outfit.getHead());
    g_lua.setField("head");
    g_lua.pushInteger(outfit.getBody());
    g_lua.setField("body");
    g_lua.pushInteger(outfit.getLegs());
    g_lua.setField("legs");
    g_lua.pushInteger(outfit.getFeet());
    g_lua.setField("feet");
    if(g_game.getFeature(Otc::GamePlayerMounts)) {
        g_lua.pushInteger(outfit.getMount());
        g_lua.setField("mount");
    }
    return 1;
}
开发者ID:AdamSC1-ddg,项目名称:otclient,代码行数:25,代码来源:luavaluecasts.cpp

示例4: DrawOutfit

void OutfitterPanel::DrawOutfit(const Outfit &outfit, const Point &center, bool isSelected, bool isOwned)
{
	const Sprite *thumbnail = outfit.Thumbnail();
	const Sprite *back = SpriteSet::Get(
		isSelected ? "ui/outfitter selected" : "ui/outfitter unselected");
	SpriteShader::Draw(back, center);
	SpriteShader::Draw(thumbnail, center);
	
	// Draw the outfit name.
	const string &name = outfit.Name();
	const Font &font = FontSet::Get(14);
	Point offset(-.5f * font.Width(name), -.5f * OUTFIT_SIZE + 10.f);
	font.Draw(name, center + offset, Color((isSelected | isOwned) ? .8 : .5, 0.));
}
开发者ID:Faileas,项目名称:endless-sky,代码行数:14,代码来源:OutfitterPanel.cpp

示例5: luavalue_cast

bool luavalue_cast(int index, Outfit& outfit)
{
    if(g_lua.isTable(index)) {
        g_lua.getField("type", index);
        outfit.setId(g_lua.popInteger());
        g_lua.getField("auxType", index);
        outfit.setAuxId(g_lua.popInteger());
        if(g_game.getFeature(Otc::GamePlayerAddons)) {
            g_lua.getField("addons", index);
            outfit.setAddons(g_lua.popInteger());
        }
        g_lua.getField("head", index);
        outfit.setHead(g_lua.popInteger());
        g_lua.getField("body", index);
        outfit.setBody(g_lua.popInteger());
        g_lua.getField("legs", index);
        outfit.setLegs(g_lua.popInteger());
        g_lua.getField("feet", index);
        outfit.setFeet(g_lua.popInteger());
        if(g_game.getFeature(Otc::GamePlayerMounts)) {
            g_lua.getField("mount", index);
            outfit.setMount(g_lua.popInteger());
        }
        return true;
    }
    return false;
}
开发者ID:AdamSC1-ddg,项目名称:otclient,代码行数:27,代码来源:luavaluecasts.cpp

示例6: Update

// Call this every time the ship changes.
void OutfitInfoDisplay::Update(const Outfit &outfit)
{
	UpdateDescription(outfit.Description());
	UpdateRequirements(outfit);
	UpdateAttributes(outfit);
	
	maximumHeight = max(descriptionHeight, max(requirementsHeight, attributesHeight));
}
开发者ID:YuriGobbi,项目名称:endless-sky,代码行数:9,代码来源:OutfitInfoDisplay.cpp

示例7: Update

// Call this every time the ship changes.
void OutfitInfoDisplay::Update(const Outfit &outfit, const PlayerInfo &player, bool canSell)
{
	UpdateDescription(outfit.Description());
	UpdateRequirements(outfit, player, canSell);
	UpdateAttributes(outfit);
	
	maximumHeight = max(descriptionHeight, max(requirementsHeight, attributesHeight));
}
开发者ID:TeoTwawki,项目名称:endless-sky,代码行数:9,代码来源:OutfitInfoDisplay.cpp

示例8: ShipCanSell

bool OutfitterPanel::ShipCanSell(const Ship *ship, const Outfit *outfit)
{
	if(!ship->OutfitCount(outfit))
		return false;
	
	// If this outfit requires ammo, check if we could sell it if we sold all
	// the ammo for it first.
	const Outfit *ammo = outfit->Ammo();
	if(ammo && ship->OutfitCount(ammo))
	{
		Outfit attributes = ship->Attributes();
		attributes.Add(*ammo, -ship->OutfitCount(ammo));
		return attributes.CanAdd(*outfit, -1);
	}
	
	// Now, check whether this ship can sell this outfit.
	return ship->Attributes().CanAdd(*outfit, -1);
}
开发者ID:Faileas,项目名称:endless-sky,代码行数:18,代码来源:OutfitterPanel.cpp

示例9: UpdateDescription

void OutfitInfoDisplay::UpdateDescription(const Outfit &outfit)
{
	description.SetAlignment(WrappedText::JUSTIFIED);
	description.SetWrapWidth(WIDTH - 20);
	description.SetFont(FontSet::Get(14));
	
	description.Wrap(outfit.Description());
	
	// Pad by 10 pixels on the top and bottom.
	descriptionHeight = description.Height() + 20;
}
开发者ID:balachia,项目名称:endless-sky,代码行数:11,代码来源:OutfitInfoDisplay.cpp

示例10: msg

void ProtocolGame::sendChangeOutfit(const Outfit& outfit)
{
    OutputMessagePtr msg(new OutputMessage);
    msg->addU8(Proto::ClientChangeOutfit);
    msg->addU16(outfit.getId());
    msg->addU8(outfit.getHead());
    msg->addU8(outfit.getBody());
    msg->addU8(outfit.getLegs());
    msg->addU8(outfit.getFeet());
    msg->addU8(outfit.getAddons());
    if(g_game.getFeature(Otc::GamePlayerMounts))
        msg->addU16(outfit.getMount());
    send(msg);
}
开发者ID:Cadyan,项目名称:otclient,代码行数:14,代码来源:protocolgamesend.cpp

示例11: setOutfit

void Creature::setOutfit(const Outfit& outfit)
{
    if(outfit.getCategory() != ThingCategoryCreature) {
        if(!g_things.isValidDatId(outfit.getAuxId(), outfit.getCategory()))
            return;
        m_outfit.setAuxId(outfit.getAuxId());
        m_outfit.setCategory(outfit.getCategory());
    } else {
        if(outfit.getId() > 0 && !g_things.isValidDatId(outfit.getId(), ThingCategoryCreature))
            return;
        m_outfit = outfit;
    }
    m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
}
开发者ID:Riverlance,项目名称:otclient,代码行数:14,代码来源:creature.cpp

示例12: sendChangeOutfit

void ProtocolGame::sendChangeOutfit(const Outfit& outfit)
{
    OutputMessage msg;
    msg.addU8(Proto::ClientChangeOutfit);

    msg.addU16(outfit.getId());
    msg.addU8(outfit.getHead());
    msg.addU8(outfit.getBody());
    msg.addU8(outfit.getLegs());
    msg.addU8(outfit.getFeet());
    msg.addU8(outfit.getAddons());

    send(msg);
}
开发者ID:Cayan,项目名称:otclient,代码行数:14,代码来源:protocolgamesend.cpp

示例13: sendSetOutfit

void ProtocolGame::sendSetOutfit(const Outfit& outfit)
{
    OutputMessage oMsg;
    oMsg.addU8(Proto::ClientSetOutfit);

    oMsg.addU16(outfit.getId());
    oMsg.addU8(outfit.getHead());
    oMsg.addU8(outfit.getBody());
    oMsg.addU8(outfit.getLegs());
    oMsg.addU8(outfit.getFeet());
    oMsg.addU8(outfit.getAddons());

    send(oMsg);
}
开发者ID:AndreFaramir,项目名称:otclient,代码行数:14,代码来源:protocolgamesend.cpp

示例14: testNames

void testNames()
{
    Dweller *d = new Dweller("Pip-Boy", 2222222);
    Outfit *o = new Outfit("Minuteman", 10, 2200220);
    Weapon *w = new Weapon("Gauss", 16, 16);
    Vec2D currentPos (3.54, 6.32 );

    // hold a list of game objects that was instantiated.
    vector<GameObject *> gameObjectList;
    gameObjectList.push_back(d);
    gameObjectList.push_back(o);
    gameObjectList.push_back(w);

    // test Dweller public functions
	d->getSPECIAL();
    d->getCurrentHealth();
    d->getCurrentRadDamage(); 
    d->getAttackDmg(); 
    d->setPosition(currentPos); 
    d->getPosition() ; 
    d->receiveHealthDamage(13); 
    d->receiveRadDamage(15); 
    d->receiveEquipmentDamage(4);
    d->addStimpak(2); 
    d->addRadAway(5); 
    d->useStimpak(); 
    d->useRadAway(); 
    d->assignOutfit(o);
    d->assignWeapon(w); 
    d->isDead() ; 

    // test Outfit public functions
    o->getSPECIAL();
    o->receiveDamage(1);

    // test Weapon public functions
    w->getAttackDmg();
    w->receiveDamage(1);

    // test Item inheritance
    Item *i = o;
    i->getDurability();
    i->receiveDamage(1);

    i = w;
    i->getDurability();
    i->receiveDamage(1);

    // test game object inheritance
    for (auto go : gameObjectList)
    {
        go->getName();
    }
    GameObject::getCount();

    // release the memory
    for (auto go : gameObjectList)
    {
       delete go;
    }
}
开发者ID:Larkie11,项目名称:Assignment-1,代码行数:61,代码来源:compileCheck.cpp

示例15: UpdateAttributes

void OutfitInfoDisplay::UpdateAttributes(const Outfit &outfit)
{
	attributeLabels.clear();
	attributeValues.clear();
	attributesHeight = 20;
	
	map<string, map<string, int>> listing;
	for(const auto &it : outfit.Attributes())
	{
		if(it.first == "outfit space"
				|| it.first == "weapon capacity" || it.first == "engine capacity"
				|| it.first == "gun ports" || it.first == "turret mounts")
			continue;
		
		string value;
		double scale = 1.;
		if(it.first == "thrust" || it.first == "reverse thrust" || it.first == "afterburner thrust")
			scale = 60. * 60.;
		else if(ATTRIBUTES_TO_SCALE.count(it.first))
			scale = 60.;
		
		if(BOOLEAN_ATTRIBUTES.count(it.first)) 
		{
			attributeLabels.push_back("This outfit is " + it.first + ".");
			attributeValues.push_back(" ");
			attributesHeight += 20;
		}
		else
		{
			attributeLabels.push_back(it.first + ':');
			attributeValues.push_back(Format::Number(it.second * scale));
			attributesHeight += 20;
		}
	}
	
	if(!outfit.IsWeapon())
		return;
	
	attributeLabels.push_back(string());
	attributeValues.push_back(string());
	attributesHeight += 10;
	
	if(outfit.Ammo())
	{
		attributeLabels.push_back("ammo:");
		attributeValues.push_back(outfit.Ammo()->Name());
		attributesHeight += 20;
	}
	
	attributeLabels.push_back("range:");
	attributeValues.push_back(Format::Number(outfit.Range()));
	attributesHeight += 20;
	
	if(outfit.ShieldDamage() && outfit.Reload())
	{
		attributeLabels.push_back("shield damage / second:");
		attributeValues.push_back(Format::Number(60. * outfit.ShieldDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.HullDamage() && outfit.Reload())
	{
		attributeLabels.push_back("hull damage / second:");
		attributeValues.push_back(Format::Number(60. * outfit.HullDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.HeatDamage() && outfit.Reload())
	{
		attributeLabels.push_back("heat damage / second:");
		attributeValues.push_back(Format::Number(60. * outfit.HeatDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.IonDamage() && outfit.Reload())
	{
		attributeLabels.push_back("ion damage / second:");
		attributeValues.push_back(Format::Number(6000. * outfit.IonDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.SlowingDamage() && outfit.Reload())
	{
		attributeLabels.push_back("slowing damage / second:");
		attributeValues.push_back(Format::Number(6000. * outfit.SlowingDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.DisruptionDamage() && outfit.Reload())
	{
		attributeLabels.push_back("disruption damage / second:");
		attributeValues.push_back(Format::Number(6000. * outfit.DisruptionDamage() / outfit.Reload()));
		attributesHeight += 20;
	}
	
	if(outfit.FiringEnergy() && outfit.Reload())
	{
		attributeLabels.push_back("firing energy / second:");
		attributeValues.push_back(Format::Number(60. * outfit.FiringEnergy() / outfit.Reload()));
		attributesHeight += 20;
//.........这里部分代码省略.........
开发者ID:TeoTwawki,项目名称:endless-sky,代码行数:101,代码来源:OutfitInfoDisplay.cpp


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