本文整理汇总了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;
}
}
}
}
}
示例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();
}
}