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


C# Target.IsValidFor方法代码示例

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


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

示例1: DoImpact

        public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
        {
            if (!target.IsValidFor(firedBy))
                return;

            var pos = target.CenterPosition;
            var world = firedBy.World;
            var targetTile = world.Map.CellContaining(pos);
            var isValid = IsValidImpact(pos, firedBy);

            if ((!world.Map.Contains(targetTile)) || (!isValid))
                return;

            var palette = ExplosionPalette;
            if (UsePlayerPalette)
                palette += firedBy.Owner.InternalName;

            var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);
            if (Image != null && explosion != null)
                world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette)));

            var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
            if (impactSound != null)
                Game.Sound.Play(impactSound, pos);
        }
开发者ID:OpenRA,项目名称:OpenRA,代码行数:25,代码来源:CreateEffectWarhead.cs

示例2: CanAttack

        protected override bool CanAttack(Actor self, Target target)
        {
            if (!target.IsValidFor(self))
                return false;

            return base.CanAttack(self, target);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:AttackFollow.cs

示例3: AttackTarget

        public void AttackTarget(Target target, bool queued, bool allowMove)
        {
            if (!target.IsValidFor(self))
                return;

            if (!queued)
                self.CancelActivity();

            self.QueueActivity(GetAttackActivity(self, target, allowMove));
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:10,代码来源:AttackBase.cs

示例4: MoveAdjacentTo

        public MoveAdjacentTo(Actor self, Target target)
        {
            Target = target;

            mobile = self.Trait<Mobile>();
            pathFinder = self.World.WorldActor.Trait<IPathFinder>();
            domainIndex = self.World.WorldActor.Trait<DomainIndex>();
            movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet);

            if (target.IsValidFor(self))
                targetPosition = self.World.Map.CellContaining(target.CenterPosition);

            repath = true;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:14,代码来源:MoveAdjacentTo.cs

示例5: CanAttack

		protected virtual bool CanAttack(Actor self, Target target)
		{
			if (!self.IsInWorld)
				return false;

			// Building is under construction or is being sold
			if (building.Value != null && !building.Value.BuildComplete)
				return false;

			if (!target.IsValidFor(self))
				return false;

			if (Armaments.All(a => a.IsReloading))
				return false;

			if (self.IsDisabled())
				return false;

			return true;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:20,代码来源:AttackBase.cs

示例6: OrderForUnit

        static UnitOrderResult OrderForUnit(Actor self, Target target, MouseInput mi)
        {
            if (self.Owner != self.World.LocalPlayer)
                return null;

            if (self.Destroyed || !target.IsValidFor(self))
                return null;

            if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action)
            {
                foreach (var o in self.TraitsImplementing<IIssueOrder>()
                    .SelectMany(trait => trait.Orders
                        .Select(x => new { Trait = trait, Order = x }))
                    .OrderByDescending(x => x.Order.OrderPriority))
                {
                    var actorsAt = self.World.ActorMap.GetUnitsAt(self.World.Map.CellContaining(target.CenterPosition)).ToList();

                    var modifiers = TargetModifiers.None;
                    if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
                        modifiers |= TargetModifiers.ForceAttack;
                    if (mi.Modifiers.HasModifier(Modifiers.Shift))
                        modifiers |= TargetModifiers.ForceQueue;
                    if (mi.Modifiers.HasModifier(Modifiers.Alt))
                        modifiers |= TargetModifiers.ForceMove;

                    string cursor = null;
                    if (o.Order.CanTarget(self, target, actorsAt, modifiers, ref cursor))
                        return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
                }
            }

            return null;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:33,代码来源:UnitOrderGenerator.cs

示例7: OrderForUnit

        /// <summary>
        /// Returns the most appropriate order for a given actor and target.
        /// First priority is given to orders that interact with the given actors.
        /// Second priority is given to actors in the given cell.
        /// </summary>
        static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actorsAt, CPos xy, MouseInput mi)
        {
            if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action)
                return null;

            if (self.Owner != self.World.LocalPlayer)
                return null;

            if (self.World.IsGameOver)
                return null;

            if (self.Disposed || !target.IsValidFor(self))
                return null;

            var modifiers = TargetModifiers.None;
            if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
                modifiers |= TargetModifiers.ForceAttack;
            if (mi.Modifiers.HasModifier(Modifiers.Shift))
                modifiers |= TargetModifiers.ForceQueue;
            if (mi.Modifiers.HasModifier(Modifiers.Alt))
                modifiers |= TargetModifiers.ForceMove;

            var orders = self.TraitsImplementing<IIssueOrder>()
                .SelectMany(trait => trait.Orders.Select(x => new { Trait = trait, Order = x }))
                .OrderByDescending(x => x.Order.OrderPriority);

            for (var i = 0; i < 2; i++)
            {
                foreach (var o in orders)
                {
                    var localModifiers = modifiers;
                    string cursor = null;
                    if (o.Order.CanTarget(self, target, actorsAt, ref localModifiers, ref cursor))
                        return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
                }

                // No valid orders, so check for orders against the cell
                target = Target.FromCell(self.World, xy);
            }

            return null;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:47,代码来源:UnitOrderGenerator.cs

示例8: CanAttack

        protected virtual bool CanAttack(Actor self, Target target)
        {
            if (!self.IsInWorld)
                return false;

            if (!target.IsValidFor(self))
                return false;

            if (Armaments.All(a => a.IsReloading))
                return false;

            if (self.IsDisabled())
                return false;

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


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