本文整理汇总了C++中CombatGroup::CountUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ CombatGroup::CountUnits方法的具体用法?C++ CombatGroup::CountUnits怎么用?C++ CombatGroup::CountUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CombatGroup
的用法示例。
在下文中一共展示了CombatGroup::CountUnits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
CombatGroup::CountUnits() const
{
int n = 0;
CombatGroup* g = (CombatGroup*) this;
ListIter<CombatUnit> unit = g->units;
while (++unit)
n += unit->Count() - unit->DeadCount();
CombatGroup* pThis = ((CombatGroup*) this);
pThis->live_comp.clear();
ListIter<CombatGroup> iter = g->components;
while (++iter) {
CombatGroup* comp = iter.value();
if (!comp->IsReserve()) {
int unit_count = comp->CountUnits();
if (unit_count > 0)
pThis->live_comp.append(comp);
n += unit_count;
}
}
return n;
}
示例2: if
CampaignMissionRequest*
CampaignPlanMission::PlanRandomStarshipMission()
{
int type = Mission::PATROL;
int r = RandomIndex();
int ownside = player_group->GetIFF();
if (mission_type_index < 0)
mission_type_index = r;
else if (mission_type_index >= 16)
mission_type_index = 0;
type = mission_types[mission_type_index++];
if (type == Mission::ESCORT_FREIGHT) {
CombatGroup* freight = campaign->FindGroup(ownside, CombatGroup::FREIGHT);
if (!freight || freight->CountUnits() < 1)
type = Mission::PATROL;
}
CampaignMissionRequest* request = 0;
request = new(__FILE__,__LINE__)
CampaignMissionRequest(campaign, type, start, player_group);
return request;
}