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


C# Actor.GetEnabledTargetTypes方法代码示例

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


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

示例1: CanGiveTo

        public bool CanGiveTo(Actor collector)
        {
            if (info.ValidFactions.Any() && !info.ValidFactions.Contains(collector.Owner.Faction.InternalName))
                return false;

            if (!info.ValidTargets.Overlaps(collector.GetEnabledTargetTypes()))
                return false;

            var positionable = collector.TraitOrDefault<IPositionable>();
            if (positionable == null)
                return false;

            return collector.World.Map.FindTilesInCircle(collector.Location, info.MaxRadius)
                .Any(c => positionable.CanEnterCell(c));
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:15,代码来源:DuplicateUnitCrateAction.cs

示例2: IsValidAgainst

        /// <summary>Checks if the warhead is valid against (can do something to) the actor.</summary>
        public virtual bool IsValidAgainst(Actor victim, Actor firedBy)
        {
            if (!AffectsParent && victim == firedBy)
                return false;

            var stance = firedBy.Owner.Stances[victim.Owner];
            if (!ValidStances.HasStance(stance))
                return false;

            // A target type is valid if it is in the valid targets list, and not in the invalid targets list.
            if (!IsValidTarget(victim.GetEnabledTargetTypes()))
                return false;

            return true;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:16,代码来源:Warhead.cs

示例3: CanAttackTarget

        protected static bool CanAttackTarget(Actor a, Actor target)
        {
            if (!a.Info.HasTraitInfo<AttackBaseInfo>())
                return false;

            var targetTypes = target.GetEnabledTargetTypes();
            if (!targetTypes.Any())
                return false;

            var arms = a.TraitsImplementing<Armament>();
            foreach (var arm in arms)
                if (arm.Weapon.IsValidTarget(targetTypes))
                    return true;

            return false;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:16,代码来源:StateBase.cs

示例4: IsValidAgainst

        /// <summary>Checks if the weapon is valid against (can target) the actor.</summary>
        public bool IsValidAgainst(Actor victim, Actor firedBy)
        {
            var targetTypes = victim.GetEnabledTargetTypes();

            if (!IsValidTarget(targetTypes))
                return false;

            // PERF: Avoid LINQ.
            foreach (var warhead in Warheads)
                if (warhead.IsValidAgainst(victim, firedBy))
                    return true;

            return false;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:15,代码来源:WeaponInfo.cs

示例5: CanTargetActor

 public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
 {
     return targetTypes.Overlaps(target.GetEnabledTargetTypes());
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:4,代码来源:UnitOrderTargeter.cs

示例6: GetAttractiveness

            /// <summary>Evaluates a single actor according to the rules defined in this consideration</summary>
            public int GetAttractiveness(Actor a, Stance stance, Player firedBy)
            {
                if (stance != Against)
                    return 0;

                if (a == null)
                    return 0;

                if (!a.IsTargetableBy(firedBy.PlayerActor))
                    return 0;

                if (Types.Overlaps(a.GetEnabledTargetTypes()))
                {
                    switch (TargetMetric)
                    {
                        case DecisionMetric.Value:
                            var valueInfo = a.Info.TraitInfoOrDefault<ValuedInfo>();
                            return (valueInfo != null) ? valueInfo.Cost * Attractiveness : 0;

                        case DecisionMetric.Health:
                            var health = a.TraitOrDefault<Health>();
                            return (health != null) ? (health.HP / health.MaxHP) * Attractiveness : 0;

                        default:
                            return Attractiveness;
                    }
                }

                return 0;
            }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:31,代码来源:SupportPowerDecision.cs


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