本文整理汇总了C#中Country.getStrength方法的典型用法代码示例。如果您正苦于以下问题:C# Country.getStrength方法的具体用法?C# Country.getStrength怎么用?C# Country.getStrength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country.getStrength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: adjustedStrength
// return the "true" strength of a territory including incoming transfers
private int adjustedStrength(Country c, int attackBias)
{
int strength = c.getStrength();
int attackers = attackBias;
int transfers = 0;
foreach (Movement m in gScreen.movements)
{
if (m.dest == c)
{
if (m.origin.getOwner() == this)
transfers++;
else
attackers++;
}
if (m.origin == c)
attackers++;
}
// only count incoming transfers if there are more of them than outgoing transfers
if (transfers >= attackers && transfers >= 0)
{
foreach (Movement m in gScreen.movements)
{
if (m.dest == c && m.origin.getOwner() == this)
strength += m.origin.getStrength() - 1;
}
}
return strength;
}
示例2: defenseValue
private float defenseValue(Country c, Dictionary<Continent, float> myContinents)
{
float myStrength = adjustedStrength(c,0) - 1;
float theirStrength = 0;
float contValue;
myContinents.TryGetValue(c.getContinent(), out contValue);
foreach (Country n in c)
{
// enemy countries nearby make this a better target for a transfer
if (n.getOwner() != this)
{
theirStrength += adjustedStrength(n, 0);
}
// if country borders a continent we control, give it some bonus
if (n.getContinent() != c.getContinent())
{
float otherVal;
myContinents.TryGetValue(n.getContinent(), out otherVal);
if (otherVal * 0.9 > contValue)
{
contValue = otherVal * 0.9f;
}
}
}
// value is ratio of their strength to ours (higher is more desirable target)
float value = theirStrength / myStrength;
// apply continent factors only to potential destinations
if(value > 1)
value = 1 + (value - 1) * contValue;
// potential sorces become easier to steal from for low-value continents
if (value < 1)
value *= contValue;
// if this country has no enemies, set value to negative its strength
if (value == 0)
value = -c.getStrength();
return value;
}