本文整理汇总了C#中Actor.SetTargetLine方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.SetTargetLine方法的具体用法?C# Actor.SetTargetLine怎么用?C# Actor.SetTargetLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.SetTargetLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
{
UnReserve();
var cell = self.World.Map.Clamp(order.TargetLocation);
var t = Target.FromCell(self.World, cell);
self.SetTargetLine(t, Color.Green);
self.CancelActivity();
self.QueueActivity(new Fly(self, t));
self.QueueActivity(new FlyCircle());
}
else if (order.OrderString == "Enter")
{
if (Reservable.IsReserved(order.TargetActor)) return;
UnReserve();
self.SetTargetLine(Target.FromOrder(self.World, order), Color.Green);
self.CancelActivity();
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
self.QueueActivity(new ResupplyAircraft());
}
else if (order.OrderString == "Stop")
{
UnReserve();
self.CancelActivity();
}
else if (order.OrderString == "ReturnToBase")
{
var airfield = ReturnToBase.ChooseAirfield(self, true);
if (airfield == null) return;
UnReserve();
self.CancelActivity();
self.SetTargetLine(Target.FromActor(airfield), Color.Green);
self.QueueActivity(new ReturnToBase(self, airfield));
self.QueueActivity(new ResupplyAircraft());
self.QueueActivity(new TakeOff());
}
else
{
// Game.Debug("Unreserve due to unhandled order: {0}".F(order.OrderString));
UnReserve();
}
}
示例2: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled || NextActivity != null)
return NextActivity;
if (trader.deliveryBuilding == null)
{
trader.deliveryBuilding = trader.ClosestDeliveryBuilding(self);
}
if (trader.deliveryBuilding == null)
{
return Util.SequenceActivities(new Wait(traderInfo.SearchForDeliveryBuildingDelay), this);
}
self.SetTargetLine(Target.FromActor(trader.deliveryBuilding), Color.Green, false);
if ((self.CenterPosition - trader.deliveryBuilding.CenterPosition).LengthSquared > WDist.FromCells(4).LengthSquared)
{
return Util.SequenceActivities(move.MoveTo(trader.deliveryBuilding.Location, 4), this);
}
if (trader.isLoaded)
{
trader.isLoaded = false;
float distance = (trader.tradeBuilding.CenterPosition - trader.deliveryBuilding.CenterPosition).HorizontalLength / 100;
PlayerResources playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
playerResources.GiveCash((int)(distance * traderInfo.DistanceMultiplier));
}
return new FindGoods(self);
}
示例3: GuardTarget
public void GuardTarget(Actor self, Target target)
{
self.SetTargetLine(target, Color.Yellow);
var range = WDist.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range);
self.QueueActivity(false, new AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, WDist.Zero, range)));
}
示例4: Tick
public override Activity Tick( Actor self )
{
if( NextActivity != null )
return NextActivity;
var mobile = self.Trait<Mobile>();
var harv = self.Trait<Harvester>();
if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
harv.ChooseNewProc(self, null);
if (harv.LinkedProc == null) // no procs exist; check again in 1s.
return Util.SequenceActivities( new Wait(25), this );
var proc = harv.LinkedProc;
var iao = proc.Trait<IAcceptOre>();
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
if( self.Location != proc.Location + iao.DeliverOffset )
return Util.SequenceActivities( mobile.MoveTo(proc.Location + iao.DeliverOffset, 0), this );
if (!isDocking)
{
isDocking = true;
iao.OnDock(self, this);
}
return Util.SequenceActivities( new Wait(10), this );
}
示例5: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled || NextActivity != null)
return NextActivity;
if (trader.tradeBuilding == null)
{
trader.tradeBuilding = trader.ClosestTradeBuilding(self);
}
if (trader.tradeBuilding == null)
{
return Util.SequenceActivities(new Wait(traderInfo.SearchForTradeBuildingDelay), this);
}
self.SetTargetLine(Target.FromActor(trader.tradeBuilding), Color.Green, false);
if ((self.CenterPosition - trader.tradeBuilding.CenterPosition).LengthSquared > WDist.FromCells(4).LengthSquared)
{
return Util.SequenceActivities(move.MoveTo(trader.tradeBuilding.Location, 4), this);
}
trader.isLoaded = true;
return new DeliverGoods(self);
}
示例6: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (reservation != null)
{
reservation.Dispose();
reservation = null;
}
if (order.OrderString == "Move")
{
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();
self.QueueActivity(new HeliFly(Util.CenterOfCell(target)));
if (Info.LandWhenIdle)
{
self.QueueActivity(new Turn(Info.InitialFacing));
self.QueueActivity(new HeliLand(true));
}
}
if (order.OrderString == "Enter")
{
if (Reservable.IsReserved(order.TargetActor)) return;
var res = order.TargetActor.TraitOrDefault<Reservable>();
if (res != null)
reservation = res.Reserve(order.TargetActor, self, this);
var exit = order.TargetActor.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
var offset = exit != null ? exit.SpawnOffset : int2.Zero;
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
self.CancelActivity();
self.QueueActivity(new HeliFly(order.TargetActor.Trait<IHasLocation>().PxPosition + offset));
self.QueueActivity(new Turn(Info.InitialFacing));
self.QueueActivity(new HeliLand(false));
QueueResupplyActivities(order.TargetActor);
}
if (order.OrderString == "ReturnToBase")
{
self.CancelActivity();
self.QueueActivity( new HeliReturn() );
}
if (order.OrderString == "Stop")
{
self.CancelActivity();
if (Info.LandWhenIdle)
{
self.QueueActivity(new Turn(Info.InitialFacing));
self.QueueActivity(new HeliLand(true));
}
}
}
示例7: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "RepairBridge")
{
var legacyHut = order.TargetActor.TraitOrDefault<LegacyBridgeHut>();
var hut = order.TargetActor.TraitOrDefault<BridgeHut>();
if (legacyHut != null)
{
if (legacyHut.BridgeDamageState == DamageState.Undamaged || legacyHut.Repairing || legacyHut.Bridge.IsDangling)
return;
}
else if (hut != null)
{
if (hut.BridgeDamageState == DamageState.Undamaged || hut.Repairing)
return;
}
else
return;
self.SetTargetLine(Target.FromOrder(self.World, order), Color.Yellow);
self.CancelActivity();
self.QueueActivity(new RepairBridge(self, order.TargetActor, info.EnterBehaviour, info.RepairNotification));
}
}
示例8: Tick
public override Activity Tick( Actor self )
{
if( IsCanceled || NextActivity != null) return NextActivity;
var harv = self.Trait<Harvester>();
if( harv.IsFull )
return Util.SequenceActivities( new DeliverResources(), NextActivity );
var mobileInfo = self.Info.Traits.Get<MobileInfo>();
var harvInfo = self.Info.Traits.Get<HarvesterInfo>();
var res = self.World.WorldActor.Trait<ResourceLayer>();
Func<int2, bool> canHarvest = loc => loc != self.Location &&
res.GetResource(loc) != null &&
harvInfo.Resources.Contains( res.GetResource(loc).info.Name );
var path = self.World.WorldActor.Trait<PathFinder>().FindPath(PathSearch.Search(self.World, mobileInfo, self.Owner, true)
.WithHeuristic(loc => canHarvest(loc) ? 0 : 1)
.FromPoint(self.Location));
if (path.Count == 0)
return NextActivity;
self.SetTargetLine(Target.FromCell(path[0]), Color.Red, false);
return Util.SequenceActivities( new MoveAdjacentTo(Target.FromCell(path[0])), new HarvestResource(self, path[0]), this );
}
示例9: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled || NextActivity != null)
return NextActivity;
var deliver = new DeliverResources(self);
if (harv.IsFull)
return Util.SequenceActivities(deliver, NextActivity);
var closestHarvestablePosition = ClosestHarvestablePos(self);
// If no harvestable position could be found, either deliver the remaining resources
// or get out of the way and do not disturb.
if (!closestHarvestablePosition.HasValue)
{
if (!harv.IsEmpty)
return deliver;
var cachedPosition = self.Location;
harv.UnblockRefinery(self);
// Only do this if UnblockRefinery did nothing.
if (self.Location == cachedPosition)
{
var unblockCell = harv.LastHarvestedCell ?? (self.Location + harvInfo.UnblockCell);
var moveTo = mobile.NearestMoveableCell(unblockCell, 2, 5);
self.QueueActivity(mobile.MoveTo(moveTo, 1));
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
}
var randFrames = self.World.SharedRandom.Next(100, 175);
return Util.SequenceActivities(NextActivity, new Wait(randFrames), this);
}
else
{
var next = this;
// Attempt to claim a resource as ours
if (territory != null)
{
if (!territory.ClaimResource(self, closestHarvestablePosition.Value))
return Util.SequenceActivities(new Wait(25), next);
}
// If not given a direct order, assume ordered to the first resource location we find:
if (!harv.LastOrderLocation.HasValue)
harv.LastOrderLocation = closestHarvestablePosition;
self.SetTargetLine(Target.FromCell(self.World, closestHarvestablePosition.Value), Color.Red, false);
var notify = self.TraitsImplementing<INotifyHarvesterAction>();
foreach (var n in notify)
n.MovingToResources(self, closestHarvestablePosition.Value, next);
return Util.SequenceActivities(mobile.MoveTo(closestHarvestablePosition.Value, 1), new HarvestResource(self), next);
}
}
示例10: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "DeliverSupplies")
{
self.SetTargetLine(Target.FromOrder(order), Color.Yellow);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor, new DonateSupplies(order.TargetActor, Info.Payload)));
}
}
示例11: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "C4")
{
self.SetTargetLine(Target.FromOrder(order), Color.Red);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor, new Demolish(order.TargetActor, Info.C4Delay)));
}
}
示例12: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
{
UnReserve();
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();
self.QueueActivity(Fly.ToCell(target));
self.QueueActivity(new FlyCircle());
}
else if (order.OrderString == "Enter")
{
if (Reservable.IsReserved(order.TargetActor)) return;
UnReserve();
self.SetTargetLine(Target.FromOrder(order), Color.Green);
self.CancelActivity();
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
QueueResupplyActivities(order.TargetActor);
}
else if (order.OrderString == "Stop")
{
UnReserve();
self.CancelActivity();
}
else if (order.OrderString == "ReturnToBase")
{
UnReserve();
self.CancelActivity();
self.QueueActivity(new ReturnToBase(self,null));
}
else
{
// Game.Debug("Unreserve due to unhandled order: {0}".F(order.OrderString));
UnReserve();
}
}
示例13: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
TargetLocation = null;
if (order.OrderString == "AttackMove")
{
TargetLocation = move.NearestMoveableCell(order.TargetLocation);
self.SetTargetLine(Target.FromCell(self.World, TargetLocation.Value), Color.Red);
Activate(self);
}
}
示例14: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
if (attackOnlyVisibleTargets && target.Type == TargetType.Actor && canHideUnderFog
&& !self.Owner.CanTargetActor(target.Actor))
{
var newTarget = Target.FromCell(self.World, self.World.Map.CellContaining(target.CenterPosition));
self.CancelActivity();
self.SetTargetLine(newTarget, Color.Green);
return Util.SequenceActivities(new HeliFly(self, newTarget));
}
// If all ammo pools are depleted and none reload automatically, return to helipad to reload and then move to next activity
// TODO: This should check whether there is ammo left that is actually suitable for the target
if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo()))
return Util.SequenceActivities(new HeliReturnToBase(self), NextActivity);
var dist = target.CenterPosition - self.CenterPosition;
// Can rotate facing while ascending
var desiredFacing = Util.GetFacing(dist, helicopter.Facing);
helicopter.Facing = Util.TickFacing(helicopter.Facing, desiredFacing, helicopter.ROT);
if (HeliFly.AdjustAltitude(self, helicopter, helicopter.Info.CruiseAltitude))
return this;
// Fly towards the target
// TODO: Fix that the helicopter won't do anything if it has multiple weapons with different ranges
// and the weapon with the longest range is out of ammo
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRange()))
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
// Fly backwards from the target
// TODO: Same problem as with MaximumRange
if (target.IsInRange(self.CenterPosition, attackHeli.GetMinimumRange()))
{
// Facing 0 doesn't work with the following position change
var facing = 1;
if (desiredFacing != 0)
facing = desiredFacing;
else if (helicopter.Facing != 0)
facing = helicopter.Facing;
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(-facing));
}
attackHeli.DoAttack(self, target);
return this;
}
示例15: ResolveOrder
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Infiltrate")
{
if (!CanInfiltrate(order.TargetActor))
return;
self.SetTargetLine(Target.FromOrder(order), Color.Red);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor, new Infiltrate(order.TargetActor)));
}
}