本文整理汇总了C++中Mission::SetIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Mission::SetIndex方法的具体用法?C++ Mission::SetIndex怎么用?C++ Mission::SetIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mission
的用法示例。
在下文中一共展示了Mission::SetIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
MissionContainer::MissionContainer(Level& aLevel, Entity& aPlayer, XMLReader& aReader, tinyxml2::XMLElement* aElement)
: Mission(aReader, aElement)
, myRequiredMissions(8)
, myOptionalMissions(8)
, myRequiredActiveMissions(8)
, myOptionalActiveMissions(8)
, myEndingMissions(8)
{
PostMaster::GetInstance()->Subscribe(eMessageType::EVENT_QUEUE_EMPTY, this);
CU::GrowingArray<Mission*> unorderedRequiredMissions(8);
CU::GrowingArray<Mission*> unorderedOptionalMissions(8);
for (tinyxml2::XMLElement* element = aReader.ForceFindFirstChild(aElement, "mission"); element != nullptr;
element = aReader.FindNextElement(element, "mission"))
{
std::string type;
aReader.ForceReadAttribute(element, "type", type);
type = CU::ToLower(type);
int missionIndex = -1;
aReader.ForceReadAttribute(element, "index", missionIndex);
bool required;
aReader.ForceReadAttribute(element, "required", required);
Mission* mission = nullptr;
if (type == "waypoint")
{
mission = new WaypointMission(aLevel, aPlayer, aReader, element);
}
else if (type == "killx")
{
mission = new KillXEnemiesMission(aLevel, aReader, element);
}
else if (type == "killxabort")
{
mission = new KillXEnemiesAbortMission(aLevel, aReader, element);
}
else if (type == "killall")
{
mission = new KillAllMission(aLevel, aReader, element);
}
else if (type == "killallabort")
{
mission = new KillAllAbortMission(aLevel, aReader, element);
}
else if (type == "survival")
{
mission = new SurvivalMission(aReader, element);
}
else if (type == "survivalabort")
{
mission = new SurvivalAbortMission(aReader, element);
}
else if (type == "defend")
{
mission = new DefendMission(aReader, element, false);
}
else if (type == "defendabort")
{
mission = new DefendMission(aReader, element, true);
}
else if (type == "killstructures")
{
mission = new KillStructureMission(aReader, element);
}
DL_ASSERT_EXP(mission != nullptr, "Missiontype not recognized: " + type);
mission->SetIndex(missionIndex);
if (required == true)
{
unorderedRequiredMissions.Add(mission);
}
else
{
unorderedOptionalMissions.Add(mission);
PostMaster::GetInstance()->SendMessage<LevelScoreMessage>(LevelScoreMessage(eLevelScoreMessageType::OPTIONAL_MISSION_ADDED));
}
}
DL_ASSERT_EXP(unorderedRequiredMissions.Size() > 0, "Need a required mission in missioncontainer");
SortCopy(myRequiredMissions, unorderedRequiredMissions);
SortCopy(myOptionalMissions, unorderedOptionalMissions);
for (int i = 0; i < myRequiredMissions.Size(); ++i)
{
myRequiredActiveMissions.Add(myRequiredMissions[i]);
}
for (int i = 0; i < myOptionalMissions.Size(); ++i)
{
myOptionalActiveMissions.Add(myOptionalMissions[i]);
}
}