當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。