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


C++ Guard::WPushBack方法代码示例

本文整理汇总了C++中Guard::WPushBack方法的典型用法代码示例。如果您正苦于以下问题:C++ Guard::WPushBack方法的具体用法?C++ Guard::WPushBack怎么用?C++ Guard::WPushBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guard的用法示例。


在下文中一共展示了Guard::WPushBack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadLevel

void GameState_BasePlayable::LoadLevel (std::string levelPath) {
	Nav->SetNavMap(0);
	ClearMap();
	objectives[0] = 0;
	objectives[1] = 0;

	GOOGLE_PROTOBUF_VERIFY_VERSION;

	std::fstream levelFile(levelPath.c_str(), std::ios::in | std::ios::binary);
	if (!levelFile.is_open()) {
//std::cout << "!levelFile.is_open()" << std::endl;
		OnLevelLoaded(false);
		return;
	}

	Level level;

	if (!level.ParseFromIstream(&levelFile)) {
//std::cout << "!level.ParseFromIstream(&levelFile)" << std::endl;
		google::protobuf::ShutdownProtobufLibrary();
		OnLevelLoaded(false);
		return;
	}

	// LOAD DATA ===
	this->levelName = level.levelname();

	SetLevelSize(sf::Vector2f(level.levelsize().x(), level.levelsize().y()));

	for (int itG = 0; itG != level.guards_size(); itG++) {
		Level_Guard* plGuard =  level.mutable_guards(itG);

		Guard* newGuard = new Guard(this, LAYER_GUARD);
		AddWorldSpace(newGuard);
		newGuard->SetPosition(sf::Vector2f(plGuard->mutable_pos()->x(), plGuard->mutable_pos()->y()));

		for (int itWP = 0; itWP != plGuard->waypoints_size(); itWP++) {
			newGuard->WPushBack(new sf::Vector2i(plGuard->mutable_waypoints(itWP)->x(),
												plGuard->mutable_waypoints(itWP)->y()));
		}
	}

	// all the simple WorldObj stuff
	for (int itS = 0; itS != level.stuff_size(); itS++) {
		Level_WorldObj* plStuff = level.mutable_stuff(itS);
		WorldDrawable* newGO = 0;
		switch (plStuff->type()) {
			case Level_WorldObjType_ROCKWALL:
				newGO = new WallRectangle(TEXTURE_ROCKWALL, Collision::STATIC, LAYER_ROCKWALL, ID_ROCKWALL);
			break;
			case Level_WorldObjType_ROCK01:
				newGO = new WallRectangle(TEXTURE_ROCK01, Collision::STATIC, LAYER_ROCK01, ID_ROCK01);
			break;
			case Level_WorldObjType_ROCK02:
				newGO = new WallRectangle(TEXTURE_ROCK02, Collision::STATIC, LAYER_ROCK02, ID_ROCK02);
			break;
			case Level_WorldObjType_BUSH:
				newGO = new WallCircle(TEXTURE_BUSH, Collision::STATIC, LAYER_BUSH, ID_BUSH);
			break;
			case Level_WorldObjType_PINE:
				newGO = new WallCircle(TEXTURE_PINE, Collision::STATIC, LAYER_PINE, ID_PINE);
			break;
			case Level_WorldObjType_ROOF:
				newGO = new WallRectangle(TEXTURE_ROOF, Collision::STATIC, LAYER_ROOF, ID_ROOF);
			break;
			case Level_WorldObjType_ROAD:
				newGO = new WorldSprite(TEXTURE_ROAD, LAYER_ROAD, ID_ROAD);
			break;
			case Level_WorldObjType_PLAYER:
				newGO = new Player(this, LAYER_PLAYER);
				player = dynamic_cast<Player*>(newGO);
			break;
			case Level_WorldObjType_PRINCESS:
				newGO = new Princess(this, LAYER_PRINCESS);
				princess = dynamic_cast<Princess*>(newGO);
			break;
			case Level_WorldObjType_COIN:
				newGO = new Coin(LAYER_COIN);
			break;
			case Level_WorldObjType_CHEST:
				newGO = new Chest(LAYER_CHEST);
				chest = dynamic_cast<Chest*>(newGO);
			break;
			case Level_WorldObjType_GOAL:
				newGO = new Goal(LAYER_GOAL);
//				goal = dynamic_cast<Goal*>(newGO);
			break;
		}
		AddWorldSpace(newGO);
		newGO->SetPosition(sf::Vector2f(plStuff->mutable_pos()->x(), plStuff->mutable_pos()->y()));
	}

	if (level.has_mission1st()) {
		Level_WorldObj* plStuff = level.mutable_mission1st();
		sf::Vector2f posMission(plStuff->mutable_pos()->x(), plStuff->mutable_pos()->y());

		switch (level.mutable_mission1st()->type()) {
			case Level_WorldObjType_CHEST:
				objectives[0] = chest;
			break;
//.........这里部分代码省略.........
开发者ID:matyicsapo,项目名称:Infiltrator,代码行数:101,代码来源:GameState_BasePlayable.cpp


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