本文整理汇总了C++中NPC::GetTribeMemberType方法的典型用法代码示例。如果您正苦于以下问题:C++ NPC::GetTribeMemberType方法的具体用法?C++ NPC::GetTribeMemberType怎么用?C++ NPC::GetTribeMemberType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPC
的用法示例。
在下文中一共展示了NPC::GetTribeMemberType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckMembers
bool Tribe::CheckMembers(const csString &type, int number)
{
// Handle special case where name is 'number'
if(type == "number")
{
// Check if total number is correct (we don't care if their idle or not
if(number < 0 || (size_t)number <= members.GetSize())
{
return true;
}
return false;
}
for(size_t i=0; i<members.GetSize(); i++)
{
NPC* member = members[i];
if(!member->GetCurrentBehavior())
{
// Discard Members with no Behavior
// This shouldn't happen but... ermm just in case
continue;
}
if((member->GetTribeMemberType() != type) && (type != "any"))
{
// Just skip any members of wrong type.
continue;
}
if(strcasecmp(member->GetCurrentBehavior()->GetName(), npcIdleBehavior.GetDataSafe()) == 0)
{
number--;
}
if(number <= 0)
{
return true;
}
}
// We don't have enough members
return false;
}
示例2: atoi
csArray<NPC*> Tribe::SelectNPCs(const csString &type, const char* number)
{
int count = atoi(number);
csArray<NPC*> npcs;
bool selectAny = type.CompareNoCase("any");
// Loop all members. Check for type and if they are idle.
for(size_t i=0; i<members.GetSize(); i++)
{
NPC* member = members[i];
if((member->GetTribeMemberType() != type) && !selectAny)
{
// Just skip any members of wrong type.
continue;
}
Behavior* currentBehavior = member->GetCurrentBehavior();
if(!currentBehavior)
{
// Newly created NPC or some malfunction.
// Just skip and try this npc next loop.
continue;
}
if(strcasecmp(currentBehavior->GetName(),npcIdleBehavior.GetDataSafe())==0)
{
count--;
npcs.Push(member);
}
// Check if we found the number requested
if(count == 0)
return npcs;
}
// Return what we found
return npcs;
}