本文整理汇总了C++中CvUnit::canRangeStrike方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::canRangeStrike方法的具体用法?C++ CvUnit::canRangeStrike怎么用?C++ CvUnit::canRangeStrike使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::canRangeStrike方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDanger
/// Updates the danger plots values to reflect threats across the map
void CvDangerPlots::UpdateDanger (bool bPretendWarWithAllCivs, bool bIgnoreVisibility)
{
// danger plots have not been initialized yet, so no need to update
if (!m_bArrayAllocated)
{
return;
}
// wipe out values
int iGridSize = GC.getMap().numPlots();
CvAssertMsg(iGridSize == m_DangerPlots.size(), "iGridSize does not match number of DangerPlots");
for (int i = 0; i < iGridSize; i++)
{
m_DangerPlots[i] = 0;
}
CvPlayer& thisPlayer = GET_PLAYER(m_ePlayer);
TeamTypes thisTeam = thisPlayer.getTeam();
// for each opposing civ
for (int iPlayer = 0; iPlayer < MAX_PLAYERS; iPlayer++)
{
PlayerTypes ePlayer = (PlayerTypes)iPlayer;
CvPlayer& loopPlayer = GET_PLAYER(ePlayer);
TeamTypes eTeam = loopPlayer.getTeam();
if (!loopPlayer.isAlive())
{
continue;
}
if (eTeam == thisTeam)
{
continue;
}
if (ShouldIgnorePlayer(ePlayer) && !bPretendWarWithAllCivs)
{
continue;
}
//for each unit
int iLoop;
CvUnit* pLoopUnit = NULL;
for (pLoopUnit = loopPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = loopPlayer.nextUnit(&iLoop))
{
if (ShouldIgnoreUnit(pLoopUnit, bIgnoreVisibility))
{
continue;
}
int iRange = pLoopUnit->baseMoves();
if (pLoopUnit->canRangeStrike())
{
iRange += pLoopUnit->GetRange();
}
CvPlot* pUnitPlot = pLoopUnit->plot();
AssignUnitDangerValue(pLoopUnit, pUnitPlot);
CvPlot* pLoopPlot = NULL;
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (int iDY = -(iRange); iDY <= iRange; iDY++)
{
pLoopPlot = plotXYWithRangeCheck(pUnitPlot->getX(), pUnitPlot->getY(), iDX, iDY, iRange);
if (!pLoopPlot || pLoopPlot == pUnitPlot)
{
continue;
}
if (!pLoopUnit->canMoveOrAttackInto(*pLoopPlot) && !pLoopUnit->canRangeStrikeAt(pLoopPlot->getX(),pLoopPlot->getY()))
{
continue;
}
AssignUnitDangerValue(pLoopUnit, pLoopPlot);
}
}
}
// for each city
CvCity* pLoopCity;
for (pLoopCity = loopPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = loopPlayer.nextCity(&iLoop))
{
if (ShouldIgnoreCity(pLoopCity, bIgnoreVisibility))
{
continue;
}
int iRange = GC.getCITY_ATTACK_RANGE();
CvPlot* pCityPlot = pLoopCity->plot();
AssignCityDangerValue(pLoopCity, pCityPlot);
CvPlot* pLoopPlot = NULL;
for (int iDX = -(iRange); iDX <= iRange; iDX++)
{
for (int iDY = -(iRange); iDY <= iRange; iDY++)
{
//.........这里部分代码省略.........