本文整理汇总了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);
}
示例2: CanAttack
protected override bool CanAttack(Actor self, Target target)
{
if (!target.IsValidFor(self))
return false;
return base.CanAttack(self, target);
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}