本文整理汇总了C++中Craft类的典型用法代码示例。如果您正苦于以下问题:C++ Craft类的具体用法?C++ Craft怎么用?C++ Craft使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Craft类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Make sure our mission forget's us, and we only delete targets we own (waypoints).
*
*/
Ufo::~Ufo()
{
for (std::vector<Target*>::iterator i = _followers.begin(); i != _followers.end();)
{
Craft *c = dynamic_cast<Craft*>(*i);
if (c)
{
c->returnToBase();
i = _followers.begin();
}
else
{
++i;
}
}
if (_mission)
{
_mission->decreaseLiveUfos();
}
if (_dest)
{
Waypoint *wp = dynamic_cast<Waypoint*>(_dest);
if (wp != 0)
{
delete _dest;
_dest = 0;
}
}
}
示例2: if
/**
* Shows the selected soldier's info.
* @param action Pointer to an action.
*/
void CraftSoldiersState::lstSoldiersClick(Action *action)
{
int row = _lstSoldiers->getSelectedRow();
Craft *c = _base->getCrafts()->at(_craft);
Soldier *s = _base->getSoldiers()->at(_lstSoldiers->getSelectedRow());
Uint8 color = Palette::blockOffset(13)+10;
if (s->getCraft() == c)
{
s->setCraft(0);
_lstSoldiers->setCellText(row, 2, _game->getLanguage()->getString("STR_NONE_UC"));
color = Palette::blockOffset(13)+10;
}
else if (c->getSpaceAvailable() > 0 && s->getWoundRecovery() == 0)
{
s->setCraft(c);
_lstSoldiers->setCellText(row, 2, c->getName(_game->getLanguage()));
color = Palette::blockOffset(13);
}
_lstSoldiers->setRowColor(row, color);
std::wstringstream ss;
ss << _game->getLanguage()->getString("STR_SPACE_AVAILABLE") << L'\x01' << c->getSpaceAvailable();
_txtAvailable->setText(ss.str());
std::wstringstream ss2;
ss2 << _game->getLanguage()->getString("STR_SPACE_USED") << L'\x01' << c->getSpaceUsed();
_txtUsed->setText(ss2.str());
}
示例3: tr
/**
* Shows the soldiers in a list.
*/
void CraftSoldiersState::init()
{
State::init();
Craft *c = _base->getCrafts()->at(_craft);
_lstSoldiers->clearList();
int row = 0;
for (std::vector<Soldier*>::iterator i = _base->getSoldiers()->begin(); i != _base->getSoldiers()->end(); ++i)
{
_lstSoldiers->addRow(3, (*i)->getName(true, 19).c_str(), tr((*i)->getRankString()).c_str(), (*i)->getCraftString(_game->getLanguage()).c_str());
Uint8 color;
if ((*i)->getCraft() == c)
{
color = Palette::blockOffset(13);
}
else if ((*i)->getCraft() != 0)
{
color = Palette::blockOffset(15)+6;
}
else
{
color = Palette::blockOffset(13)+10;
}
_lstSoldiers->setRowColor(row, color);
row++;
}
_lstSoldiers->draw();
_txtAvailable->setText(tr("STR_SPACE_AVAILABLE").arg(c->getSpaceAvailable()));
_txtUsed->setText(tr("STR_SPACE_USED").arg(c->getSpaceUsed()));
}
示例4: sCountModules
ValuePtr
sCountModules(EnvPtr env, ValuePtr args)
{
using SSM::Craft;
Craft* station = Craft::getSingleton();
return new NumberValue(station->countUnits());
}
示例5: updateQuantity
/**
* Updates the displayed quantities of the
* selected item on the list.
*/
void CraftEquipmentState::updateQuantity()
{
Craft *c = _base->getCrafts()->at(_craft);
std::wstringstream ss, ss2;
ss << _base->getItems()->getItem(_items[_sel]);
ss2 << c->getItems()->getItem(_items[_sel]);
Uint8 color;
if (c->getItems()->getItem(_items[_sel]) == 0)
{
RuleItem *rule = _game->getRuleset()->getItem(_items[_sel]);
if (rule->getBattleType() == BT_AMMO)
{
color = Palette::blockOffset(15)+6;
}
else
{
color = Palette::blockOffset(13)+10;
}
}
else
{
color = Palette::blockOffset(13);
}
_lstEquipment->setRowColor(_sel, color);
_lstEquipment->setCellText(_sel, 1, ss.str());
_lstEquipment->setCellText(_sel, 2, ss2.str());
}
示例6: lstCraftsClick
/**
* Pick a target for the selected craft.
* @param action Pointer to an action.
*/
void InterceptState::lstCraftsClick(Action *)
{
Craft* c = _crafts[_lstCrafts->getSelectedRow()];
if (c->getStatus() != "STR_OUT" && (c->getStatus() == "STR_READY" || Options::getBool("craftLaunchAlways")))
{
_game->popState();
_game->pushState(new SelectDestinationState(_game, c, _globe));
}
}
示例7: btnOkClick
/**
* Returns to the previous screen.
* @param action Pointer to an action.
*/
void CraftInfoState::btnOkClick(Action *)
{
Craft *c = _base->getCrafts()->at(_craft);
if (c->getName(_game->getLanguage()) != _edtCraft->getText())
{
c->setName(_edtCraft->getText());
}
_game->popState();
}
示例8: lstCraftsRightClick
/**
* Centers on the selected craft.
* @param action Pointer to an action.
*/
void InterceptState::lstCraftsRightClick(Action *)
{
Craft* c = _crafts[_lstCrafts->getSelectedRow()];
if (c->getStatus() == "STR_OUT")
{
_globe->center(c->getLongitude(), c->getLatitude());
_game->popState();
}
}
示例9: init
/**
* Resets the savegame when coming back from the inventory.
*/
void CraftEquipmentState::init()
{
State::init();
_game->getSavedGame()->setBattleGame(0);
Craft *c = _base->getCrafts()->at(_craft);
c->setInBattlescape(false);
}
示例10: getRow
/**
* Increases or decreases the quantity of the selected item to sell.
* @param change How much we want to add or remove.
* @param dir Direction to change, +1 to increase or -1 to decrease.
*/
void SellState::changeByValue(int change, int dir)
{
if (dir > 0)
{
if (0 >= change || getRow().qtySrc <= getRow().amount) return;
change = std::min(getRow().qtySrc - getRow().amount, change);
}
else
{
if (0 >= change || 0 >= getRow().amount) return;
change = std::min(getRow().amount, change);
}
getRow().amount += dir * change;
_total += dir * getRow().cost * change;
// Calculate the change in storage space.
Craft *craft;
Soldier *soldier;
RuleItem *armor, *item, *weapon, *ammo;
double total = 0.0;
switch (getRow().type)
{
case TRANSFER_SOLDIER:
soldier = (Soldier*)getRow().rule;
if (soldier->getArmor()->getStoreItem() != Armor::NONE)
{
armor = _game->getMod()->getItem(soldier->getArmor()->getStoreItem(), true);
_spaceChange += dir * armor->getSize();
}
break;
case TRANSFER_CRAFT:
craft = (Craft*)getRow().rule;
for (std::vector<CraftWeapon*>::iterator w = craft->getWeapons()->begin(); w != craft->getWeapons()->end(); ++w)
{
if (*w)
{
weapon = _game->getMod()->getItem((*w)->getRules()->getLauncherItem(), true);
total += weapon->getSize();
ammo = _game->getMod()->getItem((*w)->getRules()->getClipItem());
if (ammo)
total += ammo->getSize() * (*w)->getClipsLoaded(_game->getMod());
}
}
_spaceChange += dir * total;
break;
case TRANSFER_ITEM:
item = (RuleItem*)getRow().rule;
_spaceChange -= dir * change * item->getSize();
break;
default:
//TRANSFER_SCIENTIST and TRANSFER_ENGINEER do not own anything that takes storage
break;
}
updateItemStrings();
}
示例11: moveRight
/**
* Moves the selected item to the craft.
*/
void CraftEquipmentState::moveRight()
{
Craft *c = _base->getCrafts()->at(_craft);
if (_base->getItems()->getItem(_items[_sel]) > 0)
{
_base->getItems()->removeItem(_items[_sel]);
c->getItems()->addItem(_items[_sel]);
updateQuantity();
}
}
示例12: init
/**
* Resets the savegame when coming back from the inventory.
*/
void CraftEquipmentState::init()
{
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_1")->getColors());
_game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(2)), Palette::backPos, 16);
_game->getSavedGame()->setBattleGame(0);
Craft *c = _base->getCrafts()->at(_craft);
c->setInBattlescape(false);
}
示例13:
/**
* Make sure no crafts are chasing this target.
*/
Target::~Target()
{
for (size_t i = 0; i < _followers.size(); ++i)
{
Craft *craft = dynamic_cast<Craft*>(_followers[i]);
if (craft)
{
craft->returnToBase();
}
}
}
示例14: getPrice
/**
* Increases or decreases the quantity of the selected item to sell.
* @param change How much we want to add or remove.
* @param dir Direction to change, +1 to increase or -1 to decrease.
*/
void SellState::changeByValue(int change, int dir)
{
if (dir > 0)
{
if (0 >= change || getQuantity() <=_qtys[_sel]) return;
change = std::min(getQuantity() - _qtys[_sel], change);
}
else
{
if (0 >= change || 0 >= _qtys[_sel]) return;
change = std::min(_qtys[_sel], change);
}
_qtys[_sel] += dir * change;
_total += dir * getPrice() * change;
// Calculate the change in storage space.
Craft *craft;
RuleItem *armor, *item, *weapon, *ammo;
double total = 0.0;
switch (getType(_sel))
{
case SELL_SOLDIER:
if (_soldiers[_sel]->getArmor()->getStoreItem() != "STR_NONE")
{
armor = _game->getRuleset()->getItem(_soldiers[_sel]->getArmor()->getStoreItem());
_spaceChange += dir * armor->getSize();
}
break;
case SELL_CRAFT:
craft = _crafts[getCraftIndex(_sel)];
for (std::vector<CraftWeapon*>::iterator w = craft->getWeapons()->begin(); w != craft->getWeapons()->end(); ++w)
{
if (*w)
{
weapon = _game->getRuleset()->getItem((*w)->getRules()->getLauncherItem());
total += weapon->getSize();
ammo = _game->getRuleset()->getItem((*w)->getRules()->getClipItem());
if (ammo)
total += ammo->getSize() * (*w)->getClipsLoaded(_game->getRuleset());
}
}
_spaceChange += dir * total;
break;
case SELL_ITEM:
item = _game->getRuleset()->getItem(_items[getItemIndex(_sel)]);
_spaceChange -= dir * change * item->getSize();
break;
default:
break;
}
updateItemStrings();
}
示例15: moveLeft
/**
* Moves the given number of items (selected) to the base.
*/
void CraftEquipmentState::moveLeft(int change)
{
Craft *c = _base->getCrafts()->at(_craft);
RuleItem *item = _game->getRuleset()->getItem(_items[_sel]);
int cQty = 0;
if (item->isFixed()) cQty = c->getVehicleCount(_items[_sel]);
else cQty = c->getItems()->getItem(_items[_sel]);
if (0 >= change || 0 >= cQty) return;
change = std::min(cQty, change);
// Convert vehicle to item
if (item->isFixed())
{
if(item->getClipSize() != -1)
{
// First we remove all vehicles because we want to redistribute the ammo
RuleItem *ammo = _game->getRuleset()->getItem(item->getCompatibleAmmo()->front());
for (std::vector<Vehicle*>::iterator i = c->getVehicles()->begin(); i != c->getVehicles()->end(); )
{
if ((*i)->getRules() == item)
{
_base->getItems()->addItem(ammo->getType(), (*i)->getAmmo());
delete (*i);
i = c->getVehicles()->erase(i);
}
else ++i;
}
_base->getItems()->addItem(_items[_sel], cQty);
// And now reAdd the count we want to keep in the craft (and redistribute the ammo among them)
if (cQty > change) moveRight(cQty - change);
}
else
{
_base->getItems()->addItem(_items[_sel], change);
for (std::vector<Vehicle*>::iterator i = c->getVehicles()->begin(); i != c->getVehicles()->end(); )
{
if ((*i)->getRules() == item)
{
delete (*i);
i = c->getVehicles()->erase(i);
if (0 >= --change) break;
}
else ++i;
}
}
}
else
{
c->getItems()->removeItem(_items[_sel], change);
_base->getItems()->addItem(_items[_sel], change);
}
updateQuantity();
}