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


C# Actor.CancelActivity方法代码示例

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


在下文中一共展示了Actor.CancelActivity方法的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: 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

示例3: ResolveOrder

        public override void ResolveOrder(Actor self, Order order)
        {
            base.ResolveOrder(self, order);

            if (order.OrderString == "Stop")
                self.CancelActivity();
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:7,代码来源:AttackTesla.cs

示例4: ResolveOrder

		public void ResolveOrder(Actor self, Order order)
		{
			if (order.OrderString == "BeginMinefield")
				minefieldStart = order.TargetLocation;

			if (order.OrderString == "PlaceMine")
			{
				minefieldStart = order.TargetLocation;
				Minefield = new CPos[] { order.TargetLocation };
				self.CancelActivity();
				self.QueueActivity(new LayMines());
			}

			if (order.OrderString == "PlaceMinefield")
			{
				var movement = self.Trait<IPositionable>();

				Minefield = GetMinefieldCells(minefieldStart, order.TargetLocation,
					self.Info.Traits.Get<MinelayerInfo>().MinefieldDepth)
					.Where(p => movement.CanEnterCell(p)).ToArray();

				self.CancelActivity();
				self.QueueActivity(new LayMines());
			}
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:25,代码来源:Minelayer.cs

示例5: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled || self.IsDead)
                return NextActivity;

            if (!isCalculated)
                Calculate(self);

            if (dest == null)
            {
                var nearestAfld = ChooseAirfield(self, false);

                self.CancelActivity();
                if (nearestAfld != null)
                    return ActivityUtils.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle(self));
                else
                    return new FlyCircle(self);
            }

            List<Activity> landingProcedures = new List<Activity>();

            var turnRadius = CalculateTurnRadius(planeInfo.Speed);

            landingProcedures.Add(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)));
            landingProcedures.Add(new Fly(self, Target.FromPos(w2)));

            // Fix a problem when the airplane is send to resupply near the airport
            landingProcedures.Add(new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2)));
            landingProcedures.Add(new Land(self, Target.FromActor(dest)));
            landingProcedures.Add(NextActivity);

            return ActivityUtils.SequenceActivities(landingProcedures.ToArray());
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:33,代码来源:ReturnToBase.cs

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

示例7: ResolveOrder

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

            if (order.OrderString == "Move")
            {
                self.CancelActivity();
                self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation)));
                self.QueueActivity(new Turn(self.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing));
                self.QueueActivity(new HeliLand(true));
            }

            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 productionInfo = order.TargetActor.Info.Traits.GetOrDefault<ProductionInfo>();
                var offset = productionInfo != null ? productionInfo.SpawnOffset : null;
                var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;

                self.CancelActivity();
                self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec));
                self.QueueActivity(new Turn(self.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing));
                self.QueueActivity(new HeliLand(false));
                self.QueueActivity(order.TargetActor.Info.Name == "hpad"
                    ? (IActivity)new Rearm() : new Repair(true));
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:35,代码来源:Helicopter.cs

示例8: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled || self.IsDead())
                return NextActivity;

            if (!isCalculated)
                Calculate(self);

            if (dest == null)
            {
                var nearestAfld = ChooseAirfield(self, false);

                self.CancelActivity();
                if (nearestAfld != null)
                    return Util.SequenceActivities(Fly.ToCell(nearestAfld.Location), new FlyCircle());
                else
                    return new FlyCircle();
            }

            return Util.SequenceActivities(
                Fly.ToPos(w1),
                Fly.ToPos(w2),
                Fly.ToPos(w3),
                new Land(Target.FromActor(dest)),
                NextActivity);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:26,代码来源:ReturnToBase.cs

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

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

示例11: OnCapture

 public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
 {
     var facing = self.TraitOrDefault<IFacing>();
     var transform = new Transform(self, info.IntoActor) { ForceHealthPercentage = info.ForceHealthPercentage };
     if (facing != null) transform.Facing = facing.Facing;
     transform.SkipMakeAnims = info.SkipMakeAnims;
     self.CancelActivity();
     self.QueueActivity(transform);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:9,代码来源:TransformOnCapture.cs

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

示例13: ResolveOrder

		public void ResolveOrder(Actor self, Order order)
		{
			if (order.OrderString == "PortableChronoTeleport" && CanTeleport)
			{
				var maxDistance = Info.HasDistanceLimit ? Info.MaxDistance : (int?)null;
				self.CancelActivity();
				self.QueueActivity(new Teleport(null, order.TargetLocation, maxDistance, true, false, Info.ChronoshiftSound));
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:9,代码来源:PortableChrono.cs

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

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


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