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


C++ CList::AddItem方法代码示例

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


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

示例1: OnControllerEvent

void MapObject::OnControllerEvent(SControllerEvent Event)
{
	float ax,ay,az,aw;
	Matrix MVP;
	int mx=0;
	int my=0;
	float fx=0;
	float fy=0;
	__INT32 distance=0;
	TowerObject* tower;
	if (Event.Type == ECE_POINTER)
	{
		switch (Event.PointerData.Event)
		{
		case EPE_PRESSED:
			isPressed = true;
			dragDistanceX = 0;
			dragDistanceY = 0;
			break;
		case EPE_DRAGGED:
			distance= dragDistanceX*dragDistanceX + dragDistanceY*dragDistanceY;
			if (distance>50) isDrag=true;
			break;
		case EPE_RELEASED:
			
			if (isPressed)
			{			
				MVP.LoadIdentity();
				MVP.Multiply(*(CCamera3D::GetInstance()->GetProjectMatrix()));
				MVP.Multiply(*(CCamera3D::GetInstance()->GetViewMatrix()));

				ScreenPos2MapPos(Event.PointerData.X,Event.PointerData.Y,MVP,fx,fy);
				mx = __INT32(fx/scale);
				my = __INT32(fy/scale);
				if ((!isDrag)/* && ((mLogicMap[my*mWidth+mx]==OBJECT_NONE) || (mLogicMap[my*mWidth+mx]==OBJECT_TOWER))*/)
				{
					if (mx>=0 && mx<mWidth &&my>=0 && my<mHeight)
					{

						if (mLogicMap[my*mWidth+mx]==OBJECT_NONE) //click len vung dat trong'
						{
							ScreenPos2TowerPos(Event.PointerData.X,Event.PointerData.Y,MVP,mx,my);

							Log("Logic map position: %d %d", mx, my);
							if ((mx<mWidth) && (my<mHeight) && (mx>=0) && (my>=0))
							{
								if (selected == my * mWidth + mx)
								{
									selected =-1;
									drawRange = 0;
									CList<__INT32> NullList;
									UpdateTowerBuildBar(&NullList);
									return;									
								}

								selected = my * mWidth + mx;
								if ((mLogicMap[selected]==OBJECT_NONE) && 
									(mLogicMap[selected+1]==OBJECT_NONE) && 
									(mLogicMap[selected+mWidth]==OBJECT_NONE) && 
									(mLogicMap[selected+mWidth+1]==OBJECT_NONE) &&
									CPathManagement::GetInstance()->IsStillExist(selected))	//Vung dat 2x2 trong'
								{
									CStateIngame::currentBuildBar->sellButton->SetVisible(false);
									//kiem tra so button xay tru can hien
									CStateIngame::currentBuildBar->Tower1->SetVisible(true);

									Log("Truoc calc boundary");
									CalculateBoundary(mx, my, SELECTED_BUILDABLE_CELL_COLOR,0);
									Log("Sau calc boundary");
									CList<__INT32> towerList;//sau nay de thong tin cac tower co the xay tu dat' trong vao day
									towerList.AddItem(TOWER_GUN);
									UpdateTowerBuildBar(&towerList);
								}
								else	//2x2 khong trong'
								{
									CStateIngame::currentBuildBar->sellButton->SetVisible(false);
									CalculateBoundary(mx, my, SELECTED_UNBUILDABLE_CELL_COLOR,0);
									//an het cac button xay tru
									CStateIngame::currentBuildBar->Tower1->SetVisible(false);
									CStateIngame::currentBuildBar->Tower2->SetVisible(false);
									CStateIngame::currentBuildBar->Tower3->SetVisible(false);
									CStateIngame::currentBuildBar->Tower4->SetVisible(false);
								}
							}
						}
						else if(mLogicMap[my*mWidth+mx]==OBJECT_TOWER)//click len TOWER
						{
							CStateIngame::currentBuildBar->sellButton->SetVisible(true);
							tower = (CObjectManagement::GetInstance()->GetTower(MapPosition(mx,my)));
							if (!tower) 
								tower = (CObjectManagement::GetInstance()->GetTower(MapPosition(mx-1,my)));
							if (!tower) 
								tower = (CObjectManagement::GetInstance()->GetTower(MapPosition(mx-1,my-1)));
							if (!tower) 
								tower = (CObjectManagement::GetInstance()->GetTower(MapPosition(mx,my-1)));


							if (selected == tower->mPosition.mY * mWidth + tower->mPosition.mX)
								{
									selected =-1;
//.........这里部分代码省略.........
开发者ID:50802353,项目名称:wot-version2,代码行数:101,代码来源:MapObject.cpp


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