本文整理汇总了C++中CvCity::getTeam方法的典型用法代码示例。如果您正苦于以下问题:C++ CvCity::getTeam方法的具体用法?C++ CvCity::getTeam怎么用?C++ CvCity::getTeam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvCity
的用法示例。
在下文中一共展示了CvCity::getTeam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsUnderImmediateThreat
// Can this tile be attacked by an enemy unit or city next turn?
bool CvDangerPlotContents::IsUnderImmediateThreat(const CvUnit* pUnit)
{
if (!m_pPlot || !pUnit)
return false;
// Air units operate off of intercepts instead of units/cities that can attack them
if (pUnit->getDomainType() == DOMAIN_AIR)
{
if (pUnit->GetBestInterceptor(*m_pPlot))
{
return true;
}
}
else
{
// Cities in range
for (DangerCityVector::iterator it = m_apCities.begin(); it < m_apCities.end(); ++it)
{
CvCity* pCity = GET_PLAYER(it->first).getCity(it->second);
if (pCity && pCity->getTeam() != pUnit->getTeam())
{
return true;
}
}
// Units in range
for (DangerUnitVector::iterator it = m_apUnits.begin(); it < m_apUnits.end(); ++it)
{
CvUnit* pUnit = GET_PLAYER(it->first).getUnit(it->second);
if (pUnit && !pUnit->isDelayedDeath() && !pUnit->IsDead())
{
return true;
}
}
// Citadel etc in range
if (GetDamageFromFeatures(pUnit->getOwner()) > 0)
{
return true;
}
}
// Terrain damage is greater than heal rate
int iMinimumDamage = m_bFlatPlotDamage ? m_pPlot->getTurnDamage(pUnit->ignoreTerrainDamage(), pUnit->ignoreFeatureDamage(), pUnit->extraTerrainDamage(), pUnit->extraFeatureDamage()) : 0;
if (pUnit->canHeal(m_pPlot))
{
iMinimumDamage -= pUnit->healRate(m_pPlot);
}
return (iMinimumDamage > 0);
}
示例2: AddToDominanceZones
/// Add data for this cell into dominance zone information
void CvTacticalAnalysisMap::AddToDominanceZones(int iIndex, CvTacticalAnalysisCell* pCell)
{
TeamTypes ourTeam = GET_PLAYER(m_ePlayer).getTeam();
CvPlot* pPlot = GC.getMap().plotByIndex(iIndex);
// Compute zone data for this cell
CvTacticalDominanceZone newZone;
newZone.SetAreaID(pPlot->getArea());
newZone.SetWater(pPlot->isWater());
int iCityDistance = GC.getGame().GetClosestCityDistanceInTurns(pPlot);
CvCity* pCity = GC.getGame().GetClosestCityByEstimatedTurns(pPlot);
PlayerTypes eOwnerPlayer = NO_PLAYER;
TeamTypes eOwnerTeam = NO_TEAM;
//for plots far away from a city, check the owner
if (iCityDistance>2)
{
eOwnerTeam = pPlot->getTeam();
eOwnerPlayer = pPlot->getOwner();
//there is almost always a closest city, but we're not always interested
if (pCity && eOwnerPlayer!=pCity->getOwner())
pCity = NULL;
}
else if (pCity) //look at the city
{
eOwnerTeam = pCity->getTeam();
eOwnerPlayer = pCity->getOwner();
}
newZone.SetOwner(eOwnerPlayer);
newZone.SetZoneCity(pCity);
newZone.Extend(pPlot);
if(eOwnerTeam==NO_TEAM)
{
newZone.SetTerritoryType(TACTICAL_TERRITORY_NO_OWNER);
}
else if(eOwnerTeam == ourTeam)
{
newZone.SetTerritoryType(TACTICAL_TERRITORY_FRIENDLY);
}
else if(GET_TEAM(ourTeam).isAtWar(eOwnerTeam))
{
newZone.SetTerritoryType(TACTICAL_TERRITORY_ENEMY);
}
else
{
newZone.SetTerritoryType(TACTICAL_TERRITORY_NEUTRAL);
}
// Now see if we already have a matching zone
CvTacticalDominanceZone* pZone = MergeWithExistingZone(&newZone);
if(!pZone)
{
// Data populated, now add to vector
newZone.SetDominanceZoneID(m_DominanceZones.size());
m_DominanceZones.push_back(newZone);
pZone = &m_DominanceZones[m_DominanceZones.size() - 1];
}
// Set zone for this cell
pCell->SetDominanceZone(pZone->GetDominanceZoneID());
pZone->Extend(pPlot);
}
示例3: GetDanger
// Get the maximum damage unit could receive at this plot in the next turn (update this with CvUnitCombat changes!)
int CvDangerPlotContents::GetDanger(const CvUnit* pUnit, AirActionType iAirAction)
{
if (!m_pPlot || !pUnit)
return 0;
// Air units only take damage from interceptions
if (pUnit->getDomainType() == DOMAIN_AIR)
return GetAirUnitDamage(pUnit, iAirAction);
//simple caching for speedup
SUnitStats unitStats(pUnit);
if (unitStats==m_lastUnit)
return m_lastResult;
//otherwise calculate from scratch
int iPlotDamage = 0;
CvCity* pFriendlyCity = NULL;
if ( m_pPlot->isFriendlyCity(*pUnit,true) )
pFriendlyCity = m_pPlot->getPlotCity();
// Civilians can be captured - unless they would need to be embarked on this plot
if (!pUnit->IsCombatUnit() && pUnit->isNativeDomain(m_pPlot))
{
// If plot contains an enemy unit, mark it as max danger
if (m_pPlot->getBestDefender(NO_PLAYER, pUnit->getOwner(), NULL, true))
{
return MAX_INT;
}
for (DangerUnitVector::iterator it = m_apUnits.begin(); it < m_apUnits.end(); ++it)
{
CvUnit* pAttacker = GET_PLAYER(it->first).getUnit(it->second);
if ( pAttacker && !pAttacker->isDelayedDeath() && !pAttacker->IsDead())
{
// If in a city and the city can be captured, we are in highest danger
if (pFriendlyCity)
{
if (GetDanger(pFriendlyCity) + pFriendlyCity->getDamage() > pFriendlyCity->GetMaxHitPoints())
{
return MAX_INT;
}
}
// Look for a possible plot defender
else
{
IDInfo* pUnitNode = m_pPlot->headUnitNode();
CvUnit* pBestDefender = NULL;
while (pUnitNode != NULL)
{
pBestDefender = ::getUnit(*pUnitNode);
pUnitNode = m_pPlot->nextUnitNode(pUnitNode);
if (pBestDefender && pBestDefender->getOwner() == pUnit->getOwner())
{
//fix endless recursion with stacked embarked civilians: defender must also be able to attack
if (pBestDefender->IsCanDefend() && pBestDefender->IsCanAttack())
{
if (pBestDefender != pUnit)
{
if (pBestDefender->isWaiting() || !(pBestDefender->canMove()))
{
break;
}
}
}
}
pBestDefender = NULL;
}
// If there is a defender and it might be killed, high danger
if (pBestDefender && (pBestDefender->isWaiting() || !pBestDefender->canMove()))
{
if (GetDanger(pBestDefender) > pBestDefender->GetCurrHitPoints())
{
return INT_MAX;
}
}
else if (pBestDefender==NULL)
{
//Civilian could be captured on this tile
return MAX_INT;
}
}
}
}
// Damage from features (citadel)
iPlotDamage += GetDamageFromFeatures(pUnit->getOwner());
iPlotDamage += m_bFlatPlotDamage ? m_pPlot->getTurnDamage(pUnit->ignoreTerrainDamage(), pUnit->ignoreFeatureDamage(), pUnit->extraTerrainDamage(), pUnit->extraFeatureDamage()) : 0;
// Damage from cities
for (DangerCityVector::iterator it = m_apCities.begin(); it < m_apCities.end(); ++it)
{
CvCity* pCity = GET_PLAYER(it->first).getCity(it->second);
if (!pCity || pCity->getTeam() == pUnit->getTeam())
continue;
iPlotDamage += pCity->rangeCombatDamage(pUnit, NULL, false, m_pPlot);
//.........这里部分代码省略.........