当前位置: 首页>>代码示例>>C++>>正文


C++ Mission::SetIndex方法代码示例

本文整理汇总了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]);
	}
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:97,代码来源:MissionContainer.cpp


注:本文中的Mission::SetIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。