本文整理汇总了C++中CUnitTypeData::IsAttacker方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnitTypeData::IsAttacker方法的具体用法?C++ CUnitTypeData::IsAttacker怎么用?C++ CUnitTypeData::IsAttacker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnitTypeData
的用法示例。
在下文中一共展示了CUnitTypeData::IsAttacker方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetASSAULT
string CUBuild::GetASSAULT(){
NLOG("CUBuild::GetASSAULT");
const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
if(di == 0) return string("");
list<string> possibles;
float best_score = 0;
string best = "";
for(vector<CommandDescription>::const_iterator is = di->begin(); is != di->end();++is){
if(is->id<0){
CUnitTypeData* p = G->UnitDefLoader->GetUnitTypeDataByName(is->name);
if(G->Pl->feasable(p,utd)==false){
continue;
}
if(p->IsAttacker()){
float temp = G->efficiency->GetEfficiency(p->GetName());
temp /= (p->GetUnitDef()->energyCost+(p->GetUnitDef()->metalCost*45));
temp -= (G->mrand()%max(int(temp/4),1));
if(temp > best_score){
best_score = temp;
best = p->GetName();
}
}
}
}
if(best_score < 30){
return GetRAND_ASSAULT();
}
return best;
}
示例2: GetRAND_ASSAULT
string CUBuild::GetRAND_ASSAULT(){
NLOG("CUBuild::GetRAND_ASSAULT");
const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
if(di == 0) return string("");
list<string> possibles;
int defnum = 0;
for(vector<CommandDescription>::const_iterator is = di->begin(); is != di->end();++is){
if(is->id<0){
CUnitTypeData* p =G->UnitDefLoader->GetUnitTypeDataByName(is->name);
if(G->Pl->feasable(p,utd)==false) continue;
if(p->IsAttacker()){
possibles.push_back(p->GetName());
defnum++;
}
}
}
if(possibles.empty() == false){
defnum = G->mrand()%defnum;
int j = 0;
for(list<string>::iterator k = possibles.begin(); k != possibles.end(); ++k){
if(j == defnum){
return *k;
}else{
j++;
}
}
return possibles.front();
}else{
return string("");
}
}