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


C# DamageType.ToString方法代码示例

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


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

示例1: takeDamage

        public void takeDamage(DamageType damageType, double baseDamage)
        {
            double damageDealt = baseDamage;

            foreach (Chromosome c in chromosomes)
            {
                if (c.Type.ToString() == damageType.ToString())
                {
                    if (c.Increase)
                        damageDealt *= 0.5;
                    else
                        damageDealt *= 2;
                }
            }

            this.health -= (int)damageDealt;
        }
开发者ID:calebthompson,项目名称:pest-control,代码行数:17,代码来源:Critter.cs

示例2: GetTarget

        public static Obj_AI_Hero GetTarget(Obj_AI_Base champion,
            float range,
            DamageType type,
            bool ignoreShieldSpells = true,
            IEnumerable<Obj_AI_Hero> ignoredChamps = null,
            Vector3? rangeCheckFrom = null)
        {
            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List<Obj_AI_Hero>();
                }

                var damageType = (Damage.DamageType) Enum.Parse(typeof(Damage.DamageType), type.ToString());

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, _configMenu.Item("ForceFocusSelected").GetValue<bool>() ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    return SelectedTarget;
                }

                if (_configMenu != null && _configMenu.Item("TargetingMode") != null &&
                    Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu.Item("TargetingMode").GetValue<StringList>();
                    Enum.TryParse(menuItem.SList[menuItem.SelectedIndex], out Mode);
                }

                var targets =
                    HeroManager.Enemies
                        .FindAll(
                            hero =>
                                ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) &&
                                IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom));

                switch (Mode)
                {
                    case TargetingMode.LowHP:
                        return targets.MinOrDefault(hero => hero.Health);

                    case TargetingMode.MostAD:
                        return targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod);

                    case TargetingMode.MostAP:
                        return targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod);

                    case TargetingMode.Closest:
                        return
                            targets.MinOrDefault(
                                hero =>
                                    (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).Distance(
                                        hero.ServerPosition, true));

                    case TargetingMode.NearMouse:
                        return targets.Find(hero => hero.Distance(Game.CursorPos, true) < 22500); // 150 * 150

                    case TargetingMode.AutoPriority:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero));

                    case TargetingMode.LessAttack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, Damage.DamageType.Physical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.LessCast:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, Damage.DamageType.Magical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return null;
        }
开发者ID:47110572,项目名称:CN,代码行数:86,代码来源:TargetSelector.cs

示例3: GetTarget

        public static AIHeroClient GetTarget(Obj_AI_Base champion,
            float range,
            DamageType type,
            bool ignoreShieldSpells = true,
            IEnumerable<AIHeroClient> ignoredChamps = null,
            Vector3? rangeCheckFrom = null, TargetSelectionConditionDelegate conditions = null)
        {

            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List<AIHeroClient>();
                }

                var damageType = (EloBuddy.DamageType)Enum.Parse(typeof(EloBuddy.DamageType), type.ToString());

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, focusMenu["ForceFocusSelected"].Cast<CheckBox>().CurrentValue ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    return SelectedTarget;
                }

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, focusMenu["ForceFocusSelectedKeys"].Cast<CheckBox>().CurrentValue ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    if (focusMenu["ForceFocusSelectedK"].Cast<KeyBind>().CurrentValue ||
                        focusMenu["ForceFocusSelectedK2"].Cast<KeyBind>().CurrentValue)
                    {
                        return SelectedTarget;
                    }
                }

                if (_configMenu != null && _configMenu["TargetingMode"] != null && Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu["TargetingMode"].Cast<ComboBox>().CurrentValue;
                    Enum.TryParse(getMode().ToString(), out Mode);
                }

                var targets =
                   EntityManager.Heroes.Enemies
                        .FindAll(
                            hero =>
                                ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) &&
                                IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom) && (conditions == null || conditions(hero)));

                switch (Mode)
                {
                    case TargetingMode.LowHP:
                        return targets.MinOrDefault(hero => hero.Health);

                    case TargetingMode.MostAD:
                        return targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod);

                    case TargetingMode.MostAP:
                        return targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod);

                    case TargetingMode.Closest:
                        return
                            targets.MinOrDefault(
                                hero =>
                                    (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).LSDistance(
                                        hero.ServerPosition, true));

                    case TargetingMode.NearMouse:
                        return targets.MinOrDefault(hero => hero.LSDistance(Game.CursorPos, true));

                    case TargetingMode.AutoPriority:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero));

                    case TargetingMode.LessAttack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, EloBuddy.DamageType.Physical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.LessCast:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, EloBuddy.DamageType.Magical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.MostStack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero) +
                                    (1 + hero.Buffs.Where(b => StackNames.Contains(b.Name.ToLower())).Sum(t => t.Count)));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
//.........这里部分代码省略.........
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:101,代码来源:TargetSelector.cs

示例4: getResistanceForDamageType

 //Calcualtes resistance on specific type of damage
 private float getResistanceForDamageType(DamageType dmgType)
 {
     switch (dmgType)
     {
         case DamageType.Physical:
             return PhysicalResistance;
         case DamageType.PhysicalRanged:
             return RangedResistance;
         case DamageType.Fire:
             return FireResistance;
         case DamageType.Ice:
             return IceResistance;
         case DamageType.Magic:
             return MagicResistance;
         default:
             throw new NotImplementedException("You've forgot to implement add DamageType <-> resistance stat mapping for " + dmgType.ToString() +".");
     }
 }
开发者ID:JGrzybowski,项目名称:turn-based-game-prototype,代码行数:19,代码来源:UnitBase.cs


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