当前位置: 首页>>代码示例>>C#>>正文


C# Country.getContinent方法代码示例

本文整理汇总了C#中Country.getContinent方法的典型用法代码示例。如果您正苦于以下问题:C# Country.getContinent方法的具体用法?C# Country.getContinent怎么用?C# Country.getContinent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Country的用法示例。


在下文中一共展示了Country.getContinent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: attackValue

        private float attackValue(Country c, Dictionary<Continent, float> myContinents)
        {
            int attackers = 0;
            int myStrength = 0;
            foreach (Country n in c)
            {
                if (n.getOwner() == this && n.isActive == false)
                {
                    myStrength += adjustedStrength(n,1) - 1;
                    attackers++;
                }
            }

            // make sure to include any of our attacks in progress in the value
            foreach (Movement m in gScreen.movements)
            {
                if (m.dest == c && m.origin.getOwner() == this)
                {
                    myStrength += adjustedStrength(m.origin, 0);
                    attackers++;
                }
            }

            float theirStrength = adjustedStrength(c, attackers);

            // value is ratio of our strength to their's, higher is better
            float value = myStrength / theirStrength;

            // adjust desirability for continent value
            float contValue;
            myContinents.TryGetValue(c.getContinent(), out contValue);
            value = 1 + (value - 1)*contValue;
            return value;
        }
开发者ID:kzielnicki,项目名称:Brisk,代码行数:34,代码来源:AI.cs

示例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;
        }
开发者ID:kzielnicki,项目名称:Brisk,代码行数:43,代码来源:AI.cs


注:本文中的Country.getContinent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。