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


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

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


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

示例1: init

	GLvoid CBlock::init()
	{
		// 1. setup visible surfaces		
		if (isLow())
		{
			visible[BFS_TOP]		= false;			
			visible[BFS_WATER_LAVA]	= isWater() || isLava();
			visible[BFS_BOTTOM]		= !visible[BFS_WATER_LAVA];
			visible[BFS_CEILING]	= true;
		}
		else
		{
			visible[BFS_TOP]		= true;
			visible[BFS_BOTTOM]		= false;
			visible[BFS_WATER_LAVA]	= false;
			visible[BFS_CEILING]	= false;
		}

		//visible[BFS_TOP]		= false; // uncomment to see the optimization

		vector2i tests[4] =
		{
			vector2i(0,1),	// BFS_FRONT
			vector2i(0,-1), // BFS_BACK
			vector2i(-1,0), // BFS_LEFT
			vector2i(1,0),	// BFS_RIGHT
		};  

		CBlock *testBlock = NULL;
		for (GLint i=BFS_FRONT; i<=BFS_RIGHT; i++)
		{
			testBlock = CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition+tests[i]);
			visible[i] = isLow()?false:(testBlock && testBlock->isLow() || !testBlock);

			if (water || lava)
			{
				// since water and lava are submerged by 1 level we nned to handle them differently
				visible[i] = testBlock && (!testBlock->low || 
											testBlock->type==CV_BLOCK_TYPE_CLAIMED_LAND_ID ||
											testBlock->type==CV_BLOCK_TYPE_UNCLAIMED_LAND_ID);	
			}
		}

		// tmp 
		/*for (GLint v=BFS_FRONT+1; v<=BFS_WATER_LAVA; v++)
		{
			//if (v!=BFS_BOTTOM)
			{
				visible[v]=false;
			}
		}*/

		/*
			For every block change you must call:
			- block init
			- calc block height if needed
			- finalize
		*/
	}
开发者ID:gbougard,项目名称:NBK,代码行数:59,代码来源:Block.cpp

示例2: handlePickedObjects

		GLvoid CRenderManager::handlePickedObjects()
		{
			// if we are ower the menu we do not have to proccess things under the cursor
			if (CV_GAME_MANAGER->getGUIManager()->getPlayGUI()->is_mouse_over_gui())
			{
				return;
			}

			// if we are not selling or buying we don't have to process blocks (just objects TODO)
			ACTION_EVENT *ae = CV_GAME_MANAGER->getGUIManager()->getLastActionEvent();
			
			// get the block we have our cousor on
			CBlock *pickedBlock = CV_GAME_MANAGER->getPickingManager()->getLastPickedBlock();

			if (pickedBlock)
			{
				GLint type = pickedBlock->getType();

				/*if (!pickedBlock->isSellable())
				{
					return;
				}*/

				sBoundingBox *bbox = pickedBlock->getBoundingBox();

				vector3f a(bbox->A);
				vector3f b(bbox->B);
				vector3f c(bbox->C);
				vector3f d(bbox->D);
				vector3f e(bbox->E);
				vector3f f(bbox->F);
				vector3f g(bbox->G);
				vector3f h(bbox->H);

				a[1]=b[1]=c[1]=d[1]=CV_BLOCK_HEIGHT+CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f;
				e[1]=f[1]=g[1]=h[1]=CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f;

				glLineWidth(4.0f);

				if (pickedBlock->isLow())
				{
					if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS))
					{
						return;
					}

					// draw the selection box					

					if (pickedBlock->isSellable(CV_CURRENT_PLAYER_ID) && ae->message == AEM_SELL)
					{
						glColor3f(0.0f,1.0f,0.0f);
					}
					else if (pickedBlock->isBuildable(CV_CURRENT_PLAYER_ID) && ae->message != AEM_SELL)
					{
						glColor3f(0.0f,1.0f,0.0f);
					}
					else
					{
						glColor3f(1.0f,0.0f,0.0f);
					}
					
					glBegin(GL_LINES);
					{
						/*glVertex3fv(&a[0]); glVertex3fv(&b[0]);
						glVertex3fv(&b[0]); glVertex3fv(&c[0]);
						glVertex3fv(&c[0]); glVertex3fv(&d[0]);
						glVertex3fv(&d[0]); glVertex3fv(&a[0]);*/

						glVertex3fv(&e[0]); glVertex3fv(&f[0]);
						glVertex3fv(&f[0]); glVertex3fv(&g[0]);
						glVertex3fv(&g[0]); glVertex3fv(&h[0]);
						glVertex3fv(&h[0]); glVertex3fv(&e[0]);

						/*glVertex3fv(&a[0]); glVertex3fv(&e[0]);
						glVertex3fv(&b[0]); glVertex3fv(&f[0]);
						glVertex3fv(&c[0]); glVertex3fv(&g[0]);
						glVertex3fv(&d[0]); glVertex3fv(&h[0]);*/
					}
					glEnd();
				}
				else
				{		
					if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS))
						glColor3f(type==CV_BLOCK_TYPE_ROCK_ID?1.0f:0.0f,type==CV_BLOCK_TYPE_ROCK_ID?0.0f:1.0f,0.0f);
					else
						glColor3f(1.0f,0.0f,0.0f);
			
					glBegin(GL_LINES);
					{
						glVertex3fv(&a[0]); glVertex3fv(&b[0]);
						glVertex3fv(&b[0]); glVertex3fv(&c[0]);
						glVertex3fv(&c[0]); glVertex3fv(&d[0]);
						glVertex3fv(&d[0]); glVertex3fv(&a[0]);

						glVertex3fv(&e[0]); glVertex3fv(&f[0]);
						glVertex3fv(&f[0]); glVertex3fv(&g[0]);
						glVertex3fv(&g[0]); glVertex3fv(&h[0]);
						glVertex3fv(&h[0]); glVertex3fv(&e[0]);

						glVertex3fv(&a[0]); glVertex3fv(&e[0]);
//.........这里部分代码省略.........
开发者ID:Captnoord,项目名称:NBK,代码行数:101,代码来源:RenderManager.cpp


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