本文整理汇总了C++中Ship::ModelName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::ModelName方法的具体用法?C++ Ship::ModelName怎么用?C++ Ship::ModelName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::ModelName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Buy
// Add a ship, and all its outfits, to the depreciation record.
void Depreciation::Buy(const Ship &ship, int day, Depreciation *source)
{
// First, add records for all outfits the ship is carrying.
for(const auto &it : ship.Outfits())
for(int i = 0; i < it.second; ++i)
Buy(it.first, day, source);
// Then, check the base day for the ship chassis itself.
const Ship *base = GameData::Ships().Get(ship.ModelName());
if(source)
{
// Check if the source has any instances of this ship.
auto it = source->ships.find(base);
if(it != source->ships.end() && !it->second.empty())
{
day = source->Sell(it->second);
if(it->second.empty())
source->ships.erase(it);
}
else if(isStock)
{
// If we're a planet buying from the player, and the player has no
// record of how old this ship is, it's fully depreciated.
day -= MAX_AGE;
}
}
// Increment our count for this ship on this day.
++ships[base][day];
}
示例2: DrawShip
void ShopPanel::DrawShip(const Ship &ship, const Point ¢er, bool isSelected) const
{
const Sprite *sprite = ship.GetSprite().GetSprite();
const Sprite *back = SpriteSet::Get(
isSelected ? "ui/shipyard selected" : "ui/shipyard unselected");
SpriteShader::Draw(back, center);
// Make sure the ship sprite leaves 10 pixels padding all around.
float zoomSize = SHIP_SIZE - 60.f;
// Draw the ship name.
const string &name = ship.Name().empty() ? ship.ModelName() : ship.Name();
const Font &font = FontSet::Get(14);
Point offset(-.5f * font.Width(name), -.5f * SHIP_SIZE + 10.f);
font.Draw(name, center + offset, *GameData::Colors().Get("bright"));
float zoom = min(1.f, zoomSize / max(sprite->Width(), sprite->Height()));
int swizzle = GameData::PlayerGovernment()->GetSwizzle();
SpriteShader::Draw(sprite, center, zoom, swizzle);
}