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


C# Actor.SetTargetLine方法代码示例

本文整理汇总了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();
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:48,代码来源:Plane.cs

示例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);
        }
开发者ID:Holloweye,项目名称:OpenRA,代码行数:34,代码来源:DeliverGoods.cs

示例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)));
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:7,代码来源:Guard.cs

示例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 );
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:29,代码来源:DeliverResources.cs

示例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);
        }
开发者ID:Holloweye,项目名称:OpenRA,代码行数:26,代码来源:FindGoods.cs

示例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));
                }
            }
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:60,代码来源:Helicopter.cs

示例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));
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:25,代码来源:RepairsBridges.cs

示例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 );
        }
开发者ID:maruchinu,项目名称:OpenRA,代码行数:26,代码来源:FindResources.cs

示例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);
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:59,代码来源:FindResources.cs

示例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)));
     }
 }
开发者ID:Tsher,项目名称:OpenRA,代码行数:9,代码来源:SupplyTruck.cs

示例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)));
            }
        }
开发者ID:Tsher,项目名称:OpenRA,代码行数:10,代码来源:C4Demolition.cs

示例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();
            }
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:43,代码来源:Plane.cs

示例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);
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:11,代码来源:AttackMove.cs

示例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;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:52,代码来源:HeliAttack.cs

示例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)));
            }
        }
开发者ID:Tsher,项目名称:OpenRA,代码行数:13,代码来源:Infiltrates.cs


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