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


C++ CBlock::getOwner方法代码示例

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


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

示例1: init

		bool CRoomManager::init()
		{
			// register to console: TODO register some usefull stuff
			CV_GAME_MANAGER->getConsole()->registerClass(this,"ROOM MANAGER");
			CV_GAME_MANAGER->getConsole()->addParam(RLROOM,"() Reloads the rooms.");
			CV_GAME_MANAGER->getConsole()->addParam(RC,"() Prints room count.");
			CV_GAME_MANAGER->getConsole()->addParam(RC,"() Prints room count.");
			CV_GAME_MANAGER->getConsole()->addParam(SRA,"() Shows room area.");

			// construct new rooms
			CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager();
			for (GLuint y=0; y<CV_LEVEL_MAP_SIZE; y++)
			{
				for (GLuint x=0; x<CV_LEVEL_MAP_SIZE; x++)
				{
					CBlock *block = lManager->getBlock(x,y);
					if (block->isRoom() && !block->isInRoom())
					{
						if(block->getType() == CV_BLOCK_TYPE_HEART_ID && block->getOwner() == CV_PLAYER_0)
						{
							cml::vector3f position = block->getRealPosition();
							CV_GAME_MANAGER->getControlManager()->getCamera()->setPosition(cml::vector3f(position[0]+0.3, CV_CAMERA_INITIAL_HEIGHT, position[2]+1));
						}
						// we found a room tile that isn't in a room yet. we create a new room.
						CRoom *newRoom = new CRoom();
						newRoom->init(block);
						allRooms[newRoom->getIndex()] = newRoom;
						roomColors[newRoom->getIndex()] = vector3f((GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f);
					}
				}
			}

			return true;
		}
开发者ID:Captnoord,项目名称:NBK,代码行数:34,代码来源:RoomManager.cpp

示例2:

		CBlock *CRoomManager::getRoom(GLint roomType, GLubyte owner)
		{
			for (roomIter=allRooms.begin(); roomIter!=allRooms.end(); roomIter++)
			{
				CRoom *room = roomIter->second;
				CBlock *roomTile = (*room->getRoomTilesVector())[0];
				if (roomTile->getType() == roomType && roomTile->getOwner() == owner)
				{
					return roomTile;
				}
			}
			return NULL;
		}
开发者ID:Captnoord,项目名称:NBK,代码行数:13,代码来源:RoomManager.cpp

示例3: getRoomCount

		GLint CRoomManager::getRoomCount(GLint owner, GLint type)
		{
			GLint count = 0;

			for (roomIter=allRooms.begin(); roomIter!=allRooms.end(); roomIter++)
			{
				CRoom *room = roomIter->second;

				// extract owner info the first tile. this is safe since no room can have 0 tiles.
				CBlock *roomTile = (*room->getRoomTilesVector())[0];
				count+=(roomTile->getOwner() == owner && roomTile->getType() == type && !(roomTile->getType() == CV_BLOCK_TYPE_HEART_ID || roomTile->getType() == CV_BLOCK_TYPE_PORTAL_ID))?1:0;
			}

			return count;
		}
开发者ID:Captnoord,项目名称:NBK,代码行数:15,代码来源:RoomManager.cpp

示例4: addRoomTile

		GLvoid CRoomManager::addRoomTile(CBlock *block)
		{
			CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager();

			vector2i pos = block->getLogicalPosition();

			vector2i posses[] = {vector2i(-1,0),vector2i(1,0),vector2i(0,-1),vector2i(0,1)};

			bool nbrs[4];

			nbrs[0] = lManager->isSameTypeAndOwner(pos[0]-1,pos[1],block);
			nbrs[1] = lManager->isSameTypeAndOwner(pos[0]+1,pos[1],block);
			nbrs[2] = lManager->isSameTypeAndOwner(pos[0],pos[1]-1,block);
			nbrs[3] = lManager->isSameTypeAndOwner(pos[0],pos[1]+1,block);

			GLint cnt = 0;

			cnt+=nbrs[0]?1:0;
			cnt+=nbrs[1]?1:0;
			cnt+=nbrs[2]?1:0;
			cnt+=nbrs[3]?1:0;

			if (cnt==0)
			{
				// create a new room
				CRoom *newRoom = new CRoom();
				newRoom->getRoomTilesVector()->push_back(block);
				newRoom->reownTiles();
				allRooms[newRoom->getIndex()] = newRoom;
				roomColors[newRoom->getIndex()] = vector3f((GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f,(GLfloat)(rand()%101)/100.0f);

				CV_GAME_MANAGER->getConsole()->writeLine("A new room!");
			}
			else
			{
				GLint owner = -1;
				GLint roomIndex = -1;
				GLint type = -1;
				bool set = false;

				bool ok[] = {true, true, true};

				CBlock *testBlock = NULL;

				for (int i=0; i<4; i++)
				{
					if (nbrs[i])
					{
						testBlock = lManager->getBlock(pos+posses[i]);
						if (!set)
						{
							set = true;
							owner = testBlock->getOwner();
							roomIndex = testBlock->getRoomIndex();
							type = testBlock->getType();
						}
						else
						{
							ok[0] &= (owner == testBlock->getOwner());
							ok[1] &= (roomIndex == testBlock->getRoomIndex());
							ok[2] &= (type == testBlock->getType());
						}
					}
				}

				if (ok[0]&&ok[1]&&ok[2])
				{
					// all of same type, owner and room. just add this tile to this existing room
					allRooms[testBlock->getRoomIndex()]->getRoomTilesVector()->push_back(block);
					allRooms[testBlock->getRoomIndex()]->reownTiles();

					CV_GAME_MANAGER->getConsole()->writeLine("Tile added to the existing room.");
				}
				else
				{
					std::map<GLint, CBlock*> blockPerRoom;

					// we must make some merging
					for (int i=0; i<4; i++)
					{
						if (nbrs[i])
						{
							testBlock = lManager->getBlock(pos+posses[i]);
							blockPerRoom[testBlock->getRoomIndex()] = testBlock;
						}
					}

					// on this stage there are at least 2 elements in blockPerRoom.
					// take the first room and add it it all other room tiles.
					// then delete other rooms

					std::map<GLint, CBlock*>::iterator irIter = blockPerRoom.begin();

					CRoom *targetRoom = allRooms[irIter->first];

					irIter++;

					for (irIter; irIter!=blockPerRoom.end(); irIter++)
					{
						CRoom *room = allRooms[irIter->first];
//.........这里部分代码省略.........
开发者ID:Captnoord,项目名称:NBK,代码行数:101,代码来源:RoomManager.cpp


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