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


C# Actor.QueueActivity方法代码示例

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


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

示例1: ResolveOrder

        public void ResolveOrder( Actor self, Order order )
        {
            if (order.OrderString == "DeployTransform")
            {
                var info = self.Info.Traits.Get<TransformsOnDeployInfo>();

                var transInfo = Rules.Info[info.TransformsInto];

                if (transInfo.Traits.Contains<BuildingInfo>())
                {
                    var bi = transInfo.Traits.Get<BuildingInfo>();
                    if (!self.World.CanPlaceBuilding(info.TransformsInto, bi, self.Location + new int2(info.Offset[0], info.Offset[1]), self))
                    {
                        foreach (var s in info.NoTransformSounds)
                            Sound.PlayToPlayer(self.Owner, s);

                        return;
                    }

                }
                self.CancelActivity();

                // Pick the closed deploy direction to turn to
                if (self.traits.Contains<Unit>())
                {
                    // TODO: Pick the closest deploy direction
                    var bestDir = info.DeployDirections[0];

                    self.QueueActivity(new Turn(bestDir));
                }

                self.QueueActivity(new TransformIntoActor(info.TransformsInto, new int2(info.Offset[0], info.Offset[1]), info.TransferHealthPercentage, info.TransformSounds));
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:34,代码来源:TransformsOnDeploy.cs

示例2: 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

示例3: ResolveOrder

 public void ResolveOrder(Actor self, Order order)
 {
     if (order.OrderString == "C4")
     {
         self.CancelActivity();
         self.QueueActivity(new Move(order.TargetActor, 2));
         self.QueueActivity(new Demolish(order.TargetActor));
         self.QueueActivity(new Move(self.Location, 0));
     }
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:10,代码来源:C4Demolition.cs

示例4: OnDock

 public void OnDock(Actor harv, DeliverResources dockOrder)
 {
     // Todo: need to be careful about cancellation and multiple harvs
     harv.QueueActivity(new Move(self.Location + new int2(1,1), self));
     harv.QueueActivity(new Turn(96));
     harv.QueueActivity( new CallFunc( () =>
         self.traits.Get<RenderBuilding>().PlayCustomAnimThen(self, "active", () => {
             harv.traits.Get<Harvester>().Deliver(harv, self);
             harv.QueueActivity(new Move(self.Location + DeliverOffset, self));
             harv.QueueActivity(new Harvest());
     })));
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:12,代码来源:TiberiumRefinery.cs

示例5: ResolveOrder

        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString == "C4")
            {
                self.SetTargetLine(Target.FromOrder(order), Color.Red);

                var mobile = self.Trait<Mobile>();
                self.CancelActivity();
                self.QueueActivity(new Enter(order.TargetActor));
                self.QueueActivity(new Demolish(order.TargetActor, Info.C4Delay));
                self.QueueActivity(mobile.MoveTo(self.Location, 0));
            }
        }
开发者ID:Iran,项目名称:ClassicRA,代码行数:13,代码来源:C4Demolition.cs

示例6: RequestTransportNotify

        // A carryable notifying us that he'd like to be carried
        public override bool RequestTransportNotify(Actor self, Actor carryable, CPos destination)
        {
            if (busy)
                return false;

            if (ReserveCarryable(self, carryable))
            {
                self.QueueActivity(false, new PickupUnit(self, carryable, 0));
                self.QueueActivity(true, new DeliverUnit(self, destination));
                return true;
            }

            return false;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:15,代码来源:AutoCarryall.cs

示例7: FindMoreResource

        void FindMoreResource(Actor self)
        {
            var res = self.World.WorldActor.Trait<ResourceLayer>();
            var harv = self.Info.Traits.Get<HarvesterInfo>();

            self.QueueActivity(new Move(
                () =>
                {
                    return self.World.PathFinder.FindPath(PathSearch.Search(self, true)
                        .WithHeuristic(loc => (res.GetResource(loc) != null && harv.Resources.Contains( res.GetResource(loc).info.Name )) ? 0 : 1)
                        .FromPoint(self.Location));
                }));
            self.QueueActivity(new Harvest());
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:14,代码来源:Harvest.cs

示例8: ResolveOrder

        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString == "EnterTransport")
            {
                if (order.TargetActor == null) return;
                if (!CanEnter(order.TargetActor)) return;
                if (!IsCorrectCargoType(order.TargetActor)) return;

                self.SetTargetLine(Target.FromOrder(order), Color.Green);

                self.CancelActivity();
                self.QueueActivity(new MoveAdjacentTo(order.TargetActor));
                self.QueueActivity(new EnterTransport(self, order.TargetActor));
            }
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:15,代码来源:Passenger.cs

示例9: 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

示例10: 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

示例11: OnCapture

 public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
 {
     self.QueueActivity(new Transform(self, Info.IntoActor) {
         ForceHealthPercentage = Info.ForceHealthPercentage,
         Facing = self.Trait<IFacing>().Facing
     });
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:7,代码来源:TransformOnCapture.cs

示例12: 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

示例13: ResolveOrder

        public void ResolveOrder(Actor self, Order order)
        {
            if (order.OrderString == "EnterTransport")
            {
                if (order.TargetActor == null) return;
                if (!CanEnter(order.TargetActor)) return;
                if (!IsCorrectCargoType(order.TargetActor)) return;

                self.SetTargetLine(Target.FromOrder(order), Color.Green);

                var mobile = self.Trait<Mobile>();
                self.CancelActivity();
                self.QueueActivity(mobile.MoveTo(order.TargetActor.Location, 1));
                self.QueueActivity(new EnterTransport(self, order.TargetActor));
            }
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:16,代码来源:Passenger.cs

示例14: Tick

        public IActivity Tick(Actor self)
        {
            if (!target.IsValid)
                return NextActivity;

            var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
            if (limitedAmmo != null && !limitedAmmo.HasAmmo())
            {
                self.QueueActivity(new HeliReturn());
                return NextActivity;
            }

            var aircraft = self.Trait<Aircraft>();
            var info = self.Info.Traits.Get<HelicopterInfo>();
            if (aircraft.Altitude != info.CruiseAltitude)
            {
                aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
                return this;
            }

            var range = self.Trait<AttackBase>().GetMaximumRange() - 1;
            var dist = target.CenterLocation - self.CenterLocation;

            var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
            aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
            var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);

            if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
                self.CenterLocation += (rawSpeed / dist.Length) * dist;

            return this;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:32,代码来源:HeliAttack.cs

示例15: ResolveOrder

        public void ResolveOrder(Actor self, Order order)
        {
            if (reservation != null)
            {
                reservation.Dispose();
                reservation = null;
            }

            if (order.OrderString == "Move")
            {
                self.CancelActivity();
                self.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
            }

            if (order.OrderString == "Enter")
            {
                if (Reservable.IsReserved(order.TargetActor)) return;
                var res = order.TargetActor.traits.GetOrDefault<Reservable>();
                if (res != null)
                    reservation = res.Reserve(self);

                var info = self.Info.Traits.Get<PlaneInfo>();

                self.CancelActivity();
                self.QueueActivity(new ReturnToBase(self, order.TargetActor));
                self.QueueActivity(
                    info.RearmBuildings.Contains(order.TargetActor.Info.Name)
                        ? (IActivity)new Rearm() : new Repair(true));
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:30,代码来源:Plane.cs


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