本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
示例4: DrawOutfit
void OutfitterPanel::DrawOutfit(const Outfit &outfit, const Point ¢er, 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.));
}
示例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;
}
示例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));
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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.
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
//.........这里部分代码省略.........