本文整理汇总了C#中OpenRA.Traits.Target类的典型用法代码示例。如果您正苦于以下问题:C# Target类的具体用法?C# Target怎么用?C# Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Target类属于OpenRA.Traits命名空间,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: IssueOrder
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
{
if( order.OrderID == "Unload" )
return new Order( order.OrderID, self, queued );
return null;
}
示例3: IssueOrder
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order.OrderID == "DeployTransform")
return new Order(order.OrderID, self, queued);
return null;
}
示例4: FlyAttack
public FlyAttack(Actor self, Target target)
{
this.target = target;
attackPlane = self.TraitOrDefault<AttackPlane>();
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
ticksUntilTurn = attackPlane.AttackPlaneInfo.AttackTurnDelay;
}
示例5: IssueOrder
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
{
if( order.OrderID == "EnterTransport" )
return new Order( order.OrderID, self, target.Actor, queued );
return null;
}
示例6: DoImpact
// TODO: Allow maximum resource splatter to be defined. (Per tile, and in total).
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{
if (string.IsNullOrEmpty(AddsResourceType))
return;
var world = firedBy.World;
var targetTile = world.Map.CellContaining(target.CenterPosition);
var resLayer = world.WorldActor.Trait<ResourceLayer>();
var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0;
var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);
var resourceType = world.WorldActor.TraitsImplementing<ResourceType>()
.FirstOrDefault(t => t.Info.Name == AddsResourceType);
if (resourceType == null)
Log.Write("debug", "Warhead defines an invalid resource type '{0}'".F(AddsResourceType));
else
{
foreach (var cell in allCells)
{
if (!resLayer.CanSpawnResourceAt(resourceType, cell))
continue;
var splash = world.SharedRandom.Next(1, resourceType.Info.MaxDensity - resLayer.GetResourceDensity(cell));
resLayer.AddResource(resourceType, cell, splash);
}
}
}
示例7: ResolveOrder
public override void ResolveOrder(Actor self, Order order)
{
base.ResolveOrder(self, order);
if (order.OrderString == "Stop")
target = Target.None;
}
示例8: CanAttack
protected override bool CanAttack(Actor self, Target target)
{
if (!target.IsValidFor(self))
return false;
return base.CanAttack(self, target);
}
示例9: IssueOrder
public Order IssueOrder( Actor self, IOrderTargeter order, Target target )
{
if( order.OrderID == "Disguise" )
return new Order( order.OrderID, self, target.Actor );
return null;
}
示例10: IssueOrder
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
{
if( order.OrderID == "SetRallyPoint" )
return new Order(order.OrderID, self, false) { TargetLocation = target.CenterPosition.ToCPos() };
return null;
}
示例11: Enter
protected Enter(Actor self, Actor target, int maxTries = 1, bool targetCenter = false)
{
this.move = self.Trait<IMove>();
this.target = Target.FromActor(target);
this.maxTries = maxTries;
this.targetCenter = targetCenter;
}
示例12: FlyFollow
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange)
{
this.target = target;
plane = self.Trait<Aircraft>();
this.minRange = minRange;
this.maxRange = maxRange;
}
示例13: DoImpact
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{
var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :
firedBy.World.FindActorsInCircle(target.CenterPosition, Range);
foreach (var a in actors)
{
// Don't do anything on friendly fire
if (a.Owner == firedBy.Owner)
continue;
if (Duration == 0)
a.ChangeOwner(firedBy.Owner); // Permanent
else
{
var tempOwnerManager = a.TraitOrDefault<TemporaryOwnerManager>();
if (tempOwnerManager == null)
continue;
tempOwnerManager.ChangeOwner(a, firedBy.Owner, Duration);
}
// Stop shooting, you have new enemies
a.CancelActivity();
}
}
示例14: TryGetAlternateTargetInCircle
protected bool TryGetAlternateTargetInCircle(
Actor self, WDist radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null)
{
var diff = new WVec(radius, radius, WDist.Zero);
var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff)
.Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared })
.Where(p => p.Ls <= radius.LengthSquared).OrderBy(p => p.Ls).Select(p => p.Actor);
if (preferenceFilters != null)
foreach (var filter in preferenceFilters)
{
var preferredCandidate = candidates.FirstOrDefault(filter);
if (preferredCandidate == null)
continue;
target = Target.FromActor(preferredCandidate);
update(target);
return true;
}
var candidate = candidates.FirstOrDefault();
if (candidate == null)
return false;
target = Target.FromActor(candidate);
update(target);
return true;
}
示例15: CanAttack
protected override bool CanAttack(Actor self, Target target)
{
if (!IsReachableTarget(target, true))
return false;
return base.CanAttack(self, target);
}