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


C++ CUnit::GetRect方法代码示例

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


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

示例1: Select

void CCommander::Select(float dt)
{
	hgeRect* rect = m_pSelectSqure->GetRect();
	if(m_pHge->Input_KeyDown(HGEK_LBUTTON))m_IsOneSlt = false;
	if(m_pHge->Input_GetKeyState(HGEK_LBUTTON))
	{
		if(m_pSelectSqure->IsPress())//多选
		{			
			for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
			{
				CUnit* unit = *itr;
				if (rect->Intersect(unit->GetRect()))
				{
					if (!unit->IsSelected() && unit->m_camp == m_camp)
					{
						unit->SetSelected(true);
						m_IsOneSlt = true;
					}
				}
				else
				{
					if (unit->IsSelected())
					{
						unit->SetSelected(false);
					}
				}
			}

		}else//单选
		{
			for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
			{
				CUnit* unit = *itr;
				if(unit->IsSelected())
				{
					unit->SetSelected(false);
				}
			}
			for(UNITS::reverse_iterator itr = m_units->rbegin();itr != m_units->rend();itr ++)
			{
				CUnit* unit = *itr;
				Point pos = m_pSelectSqure->GetMousePoint();
				if(unit->GetRect()->TestPoint(pos.x, pos.y))
				{
					if(!unit->IsSelected())
					{
						unit->SetSelected(true);
						if(unit->m_camp == m_camp)
						m_IsOneSlt = true;
					}
					break;
				}
			}

		}
	}
}
开发者ID:fg5823820,项目名称:TestBed2,代码行数:57,代码来源:Commander.cpp

示例2: Move

void CCommander::Move(float dt)
{
	if(m_pHge->Input_KeyDown(HGEK_RBUTTON))//右键行走
	{
		Point pos = m_pSelectSqure->GetMousePoint();
		CUnit* tagetunit = NULL;
		bool attack = false;
		for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
		{
			CUnit* unit = *itr;
			if (unit->GetRect()->TestPoint(pos.x, pos.y))
			{
				if (unit->m_camp + m_camp == 0) 
				{
					attack = true;
					tagetunit = unit;
				}
			}
		}

		POS_LIST* list = NULL;
		//if(!attack)
			list = CUnit::GetPointList(
			pos.x/m_pMap->m_tileWidth,
			pos.y/m_pMap->m_tileHeight,
			m_pMap->m_map);

		for(UNITS_ITR itr = m_units->begin();itr != m_units->end();itr ++)
		{
			CUnit* unit = *itr;
			if(unit->IsSelected() && unit->m_camp == m_camp)
			{
				if(attack)
				{
					unit->SetAttackTaget(tagetunit);
				}
				//else
				//{
					if(list->size() > 0)
					{
						long pos = list->front();
						float posx = (POS_X(pos))*m_pMap->m_tileWidth;
						float posy = (POS_Y(pos))*m_pMap->m_tileHeight;
						unit->SetDst(Point(posx,posy));
						list->pop();
					}
				//}
			}
		}
		//if(!attack)
			list->c.clear();
	}
}
开发者ID:fg5823820,项目名称:TestBed2,代码行数:53,代码来源:Commander.cpp


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