本文整理汇总了C++中Path::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::GetLength方法的具体用法?C++ Path::GetLength怎么用?C++ Path::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindNearest
int NavDijkstra::FindNearest(const Vector2& start, int type, Path& aPath, int iTurn)
{
Init(start, iTurn);
// Browse
for (m_iHead = 0 ; m_iHead < m_aStep.size() && m_iHead < m_iQueue ; ++m_iHead)
{
uint id = m_aStep[m_iHead];
Case& oCase = m_oPathGrid.GetCase(id);
ASSERT(oCase.iCount != BLOCK);
Vector2 vCoord = m_oPathGrid.GetCoord(id);
ASSERT(m_oPathGrid.GetIndex(vCoord) == id);
int dir_offset = rand() % CardDirCount;
for (int dir = 0 ; dir < CardDirCount ; ++dir)
{
Vector2 vSideCoord = m_oPathGrid.GetCoord(vCoord, (EDirection)((dir + dir_offset)%CardDirCount));
Case& oSideCase = m_oPathGrid.GetCase(vSideCoord);
if (oSideCase.iCount == BLANK)
{
oSideCase.iCount = oCase.iCount + 1;
oSideCase.iPreviousCase = id;
ASSERT(m_oPathGrid.DistanceSq(m_oPathGrid.GetCoord(id), vSideCoord) == 1);
uint iSideId = m_oPathGrid.GetIndex(vSideCoord);
m_aStep[m_iQueue++] = iSideId;
}
const Square& square = m_pModelGrid->GetCase(vSideCoord);
if (!square.IsWater())
{
int sqtype = None;
if (!square.IsDiscovered(iTurn)) sqtype |= Undiscovered;
if (!square.IsVisible()) sqtype |= Unvisible;
if (square.IsFood()) sqtype |= Food;
if (square.IsEnemyHill()) sqtype |= EnemyHill;
if (square.HasEnemyAnt()) sqtype |= EnemyAnt;
if (square.IsFriendHill()) sqtype |= FriendHill;
if (square.HasFriendAnt()) sqtype |= FriendAnt;
if (square.GetAntInfluence() > 0) sqtype |= Safe;
if (type & sqtype)
{
GetPath((oSideCase.iCount == BLOCK ? vCoord : vSideCoord), aPath);
ASSERT(aPath.GetLength() > 0);
return sqtype;
}
}
}
}
return None;
}