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


C++ Pokemon::levelUpTo方法代码示例

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


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

示例1: generateLevel


//.........这里部分代码省略.........
	std::uniform_int_distribution<int> yDistribution { 0, (height - 1) };

	auto finishRoomX = xDistribution(engine);
	auto finishRoomY = yDistribution(engine);

	if (floorIndex <= 0)
	{
		dungeon->setStartRoom(dungeon->getRoom(finishRoomX, finishRoomY, floorIndex));
	}

	if (floorIndex > 0)
	{
		while (startRoomX == finishRoomX && startRoomY == finishRoomY)
		{
			finishRoomX = xDistribution(engine);
			finishRoomY = yDistribution(engine);
		}

		dungeon->getRoom(finishRoomX, finishRoomY, floorIndex - 1)->setRoom(Direction::DOWN, dungeon->getRoom(finishRoomX, finishRoomY, floorIndex));
		dungeon->getRoom(finishRoomX, finishRoomY, floorIndex)->setRoom(Direction::UP, dungeon->getRoom(finishRoomX, finishRoomY, floorIndex - 1));
	}

	if (floorIndex < (MAX_DUNGEON_LEVEL - 1))
	{
		int nPokemon = static_cast<int>((dungeon->getWidth() * dungeon->getHeight()) * POKEMON_PER_ROOM);
		Pokemon* pokemon = nullptr;

		for (auto counter = 0; counter < nPokemon; ++counter)
		{
			pokemon = pokemonGenerator_->getRandomPokemon();

			if (pokemon != nullptr)
			{
				pokemon->levelUpTo(floorIndex + 1);
				pokemon->setCurrentRoom(dungeon->getRoom(xDistribution(engine), yDistribution(engine), floorIndex));
			}
		}

		auto nItems =static_cast<int>((dungeon->getWidth() * dungeon->getHeight()) * ITEMS_PER_ROOM);

		for (auto counter = 0; counter < nItems; ++counter)
		{
			dungeon->getRoom(xDistribution(engine), yDistribution(engine), floorIndex)->addItem(itemGenerator_->getRandomItem());
		}

		auto nTraps = static_cast<int>((dungeon->getWidth() * dungeon->getHeight()) * TRAPS_PER_ROOM);

		Room* trapRoom;
		std::map<Direction, Trap*>* traps = nullptr;
		std::map<Direction, Room*> rooms;
		std::vector<Direction> directions;
		Direction randomDirection;
		bool setTrap;

		for (auto counter = 0; counter < nTraps; ++counter)
		{
			setTrap = false;

			do
			{
				trapRoom = dungeon->getRoom(xDistribution(engine), yDistribution(engine), floorIndex);
				traps = trapRoom->getTraps();
				rooms = trapRoom->getAccessableRooms();

				if (traps->size() < rooms.size())
				{
开发者ID:Metalmate,项目名称:CPP-ALG,代码行数:67,代码来源:DungeonGenerator.cpp


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