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


C# Actor.Destroy方法代码示例

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


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

示例1: DoTransform

        void DoTransform(Actor self)
        {
            // Hack: repeat the first frame of the make anim instead
            // of flashing the full structure for a frame
            if (rb != null)
                rb.PlayCustomAnim(self, "make");

            self.World.AddFrameEndTask(w =>
            {
                var selected = w.Selection.Contains(self);

                self.Destroy();
                foreach (var s in sounds)
                    Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);

                var init = new TypeDictionary
                {
                    new LocationInit( self.Location + offset ),
                    new OwnerInit( self.Owner ),
                    new FacingInit( facing ),
                };
                if (self.HasTrait<Health>())
                    init.Add( new HealthInit( self.Trait<Health>().HPFraction ));

                var a = w.CreateActor( actor, init );

                if (selected)
                    w.Selection.Add(w, a);
            });
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:30,代码来源:Transform.cs

示例2: Tick

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

            self.World.AddFrameEndTask(w =>
            {
                var selected = w.Selection.Contains(self);

                self.Destroy();
                foreach (var s in Sounds)
                    Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);

                var init = new TypeDictionary
                {
                    new LocationInit( self.Location + Offset ),
                    new OwnerInit( self.Owner ),
                    new FacingInit( Facing ),
                };
                var health = self.TraitOrDefault<Health>();
                if (health != null)
                {
                    // TODO: Fix bogus health init
                    if (ForceHealthPercentage > 0)
                        init.Add( new HealthInit( ForceHealthPercentage * 1f / 100 ));
                    else
                        init.Add( new HealthInit( (float)health.HP / health.MaxHP ));
                }
                var a = w.CreateActor( ToActor, init );

                if (selected)
                    w.Selection.Add(w, a);
            });

            return this;
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:35,代码来源:Transform.cs

示例3: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled)
                return NextActivity;
            if (target == null || !target.IsInWorld || target.IsDead())
                return NextActivity;
            if (target.Owner == self.Owner)
                return NextActivity;

            var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
            var health = target.Trait<Health>();
            int damage = health.MaxHP / 4;

            // Need to be next to building, TODO: stop capture when going away
            var mobile = self.Trait<Mobile>();
            var nearest = target.OccupiesSpace.NearestCellTo(mobile.toCell);
            if ((nearest - mobile.toCell).LengthSquared > 2)
                return Util.SequenceActivities(new MoveAdjacentTo(Target.FromActor(target)), this);

            if (!capturesInfo.Sabotage || (capturesInfo.Sabotage && health.DamageState == DamageState.Heavy))
            {
                if (!target.Trait<Capturable>().BeginCapture(target, self))
                    return NextActivity;
            }
            else
               	target.InflictDamage(self, damage, null);

            if (capturesInfo != null && capturesInfo.WastedAfterwards)
                self.World.AddFrameEndTask(w => self.Destroy());

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

示例4: Tick

        public override Activity Tick(Actor self)
        {
            if (self.CenterPosition.Z <= 0)
            {
                if (info.Explosion != null)
                {
                    var weapon = self.World.Map.Rules.Weapons[info.Explosion.ToLowerInvariant()];

                    // Use .FromPos since this actor is killed. Cannot use Target.FromActor
                    weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
                }

                self.Destroy();
                return null;
            }

            if (info.Spins)
            {
                spin += acceleration;
                aircraft.Facing = (aircraft.Facing + spin) % 256;
            }

            var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero;
            move -= new WVec(WRange.Zero, WRange.Zero, info.Velocity);
            aircraft.SetPosition(self, aircraft.CenterPosition + move);

            return this;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:28,代码来源:FallToEarth.cs

示例5: Tick

        public override Activity Tick(Actor self)
        {
            var capturing = self.TraitOrDefault<Capturable>();
            if (capturing != null && capturing.CaptureInProgress) return NextActivity;

            var h = self.TraitOrDefault<Health>();
            var si = self.Info.Traits.Get<SellableInfo>();
            var pr = self.Owner.PlayerActor.Trait<PlayerResources>();

            var cost = self.GetSellValue();

            var refund = (cost * si.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP));
            pr.GiveCash(refund);

            foreach (var ns in self.TraitsImplementing<INotifySold>())
                ns.Sold(self);

            if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
                self.World.AddFrameEndTask(
                    w => w.Add(new CashTick(refund, 30, 2,
                        self.CenterLocation,
                        self.Owner.ColorRamp.GetColor(0))));

            self.Destroy();
            return this;
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:26,代码来源:Sell.cs

示例6: OnInside

 protected override void OnInside(Actor self)
 {
     if (health.DamageState == DamageState.Undamaged)
         return;
     target.InflictDamage(self, -health.MaxHP, null);
     self.Destroy();
 }
开发者ID:ushardul,项目名称:OpenRA,代码行数:7,代码来源:RepairBuilding.cs

示例7: Tick

        public override IActivity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
            if (target.Owner == self.Owner) return NextActivity;

            if( !target.Trait<IOccupySpace>().OccupiedCells().Any( x => x.First == self.Location ) )
                return NextActivity;

            // todo: clean this up
            self.World.AddFrameEndTask(w =>
            {
                // momentarily remove from world so the ownership queries don't get confused
                var oldOwner = target.Owner;
                w.Remove(target);
                target.Owner = self.Owner;
                w.Add(target);

                foreach (var t in target.TraitsImplementing<INotifyCapture>())
                    t.OnCapture(target, self, oldOwner, self.Owner);

                foreach (var t in self.World.Queries.WithTrait<INotifyOtherCaptured>())
                    t.Trait.OnActorCaptured(t.Actor, target, self, oldOwner, self.Owner);

                self.Destroy();
            });
            return this;
        }
开发者ID:FMode,项目名称:OpenRA,代码行数:28,代码来源:CaptureBuilding.cs

示例8: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
            if (target.Owner == self.Owner) return NextActivity;

            if( !target.OccupiesSpace.OccupiedCells().Any( x => x.First == self.Location ) )
                return NextActivity;

            foreach (var t in target.TraitsImplementing<IAcceptSpy>())
                t.OnInfiltrate(target, self);

            if (self.HasTrait<DontDestroyWhenInfiltrating>())
                self.World.AddFrameEndTask(w =>
                {
                    if (self.Destroyed) return;
                    w.Remove(self);
                });
            else
                self.Destroy();

            if (target.HasTrait<Building>())
                Sound.PlayToPlayer(self.Owner, "bldginf1.aud");

            return this;
        }
开发者ID:VrKomarov,项目名称:OpenRA,代码行数:26,代码来源:Infiltrate.cs

示例9: OnInside

 protected override void OnInside(Actor self)
 {
     if (hut.BridgeDamageState == DamageState.Undamaged || hut.Repairing || hut.Bridge.GetHut(0) == null || hut.Bridge.GetHut(1) == null)
         return;
     hut.Repair(self);
     self.Destroy();
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:RepairBridge.cs

示例10: Tick

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

            self.World.AddFrameEndTask(w =>
            {
                if (self.IsDead())
                    return;

                foreach (var nt in self.TraitsImplementing<INotifyTransform>())
                    nt.OnTransform(self);

                var selected = w.Selection.Contains(self);
                var controlgroup = w.Selection.GetControlGroupForActor(self);

                self.Destroy();
                foreach (var s in Sounds)
                    Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);

                var init = new TypeDictionary
                {
                    new LocationInit(self.Location + Offset),
                    new OwnerInit(self.Owner),
                    new FacingInit(Facing),
                };

                if (SkipMakeAnims)
                    init.Add(new SkipMakeAnimsInit());

                if (Race != null)
                    init.Add(new RaceInit(Race));

                var health = self.TraitOrDefault<Health>();
                if (health != null)
                {
                    var newHP = (ForceHealthPercentage > 0)
                        ? ForceHealthPercentage / 100f
                        : (float)health.HP / health.MaxHP;

                    init.Add(new HealthInit(newHP));
                }

                var cargo = self.TraitOrDefault<Cargo>();
                if (cargo != null)
                    init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));

                var a = w.CreateActor(ToActor, init);
                foreach (var nt in self.TraitsImplementing<INotifyTransform>())
                    nt.AfterTransform(a);

                if (selected)
                    w.Selection.Add(w, a);
                if (controlgroup.HasValue)
                    w.Selection.AddToControlGroup(a, controlgroup.Value);
            });

            return this;
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:59,代码来源:Transform.cs

示例11: Tick

		public override Activity Tick(Actor self)
		{
			if (target.Type != TargetType.Actor)
				return NextActivity;

			var capturable = target.Actor.Trait<ExternalCapturable>();

			if (IsCanceled || !self.IsInWorld || self.IsDead() || !target.IsValidFor(self))
			{
				if (capturable.CaptureInProgress)
					capturable.EndCapture();

				return NextActivity;
			}

			var mobile = self.Trait<Mobile>();
			var nearest = target.Actor.OccupiesSpace.NearestCellTo(mobile.toCell);

			if ((nearest - mobile.toCell).LengthSquared > 2)
				return Util.SequenceActivities(new MoveAdjacentTo(self, target), this);

			if (!capturable.CaptureInProgress)
				capturable.BeginCapture(self);
			else
			{
				if (capturable.Captor != self) return NextActivity;

				if (capturable.CaptureProgressTime % 25 == 0)
				{
					self.World.Add(new FlashTarget(target.Actor, self.Owner));
					self.World.Add(new FlashTarget(self));
				}

				if (capturable.CaptureProgressTime == capturable.Info.CaptureCompleteTime * 25)
				{
					var capturesInfo = self.Info.Traits.Get<ExternalCapturesInfo>();

					self.World.AddFrameEndTask(w =>
					{
						if (target.Actor.IsDead())
							return;

						var oldOwner = target.Actor.Owner;

						target.Actor.ChangeOwner(self.Owner);

						foreach (var t in target.Actor.TraitsImplementing<INotifyCapture>())
							t.OnCapture(target.Actor, self, oldOwner, self.Owner);

						capturable.EndCapture();

						if (capturesInfo != null && capturesInfo.ConsumeActor)
							self.Destroy();
					});
				}
			}
			return this;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:58,代码来源:ExternalCaptureActor.cs

示例12: OnInside

        protected override void OnInside(Actor self)
        {
            if (target.IsDead())
                return;

            target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
            self.Destroy();

            if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
                self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:11,代码来源:DonateSupplies.cs

示例13: ReplaceWithActor

 public ReplaceWithActor(Actor self, ReplaceWithActorInfo info)
 {
     self.World.AddFrameEndTask(w =>
     {
         self.Destroy();
         w.CreateActor(info.Actor, new TypeDictionary
         {
             new LocationInit( self.Location ),
             new OwnerInit( self.Owner ),
         });
     });
 }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:12,代码来源:ReplaceWithActor.cs

示例14: Tick

        public IActivity Tick(Actor self)
        {
            if (target == null || target.IsDead()) return NextActivity;
            if (target.Owner == self.Owner) return NextActivity;

            foreach (var t in target.TraitsImplementing<IAcceptSpy>())
                t.OnInfiltrate(target, self);

            self.Destroy();

            return NextActivity;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:12,代码来源:Infiltrate.cs

示例15: Tick

        public IActivity Tick(Actor self)
        {
            if (target == null || target.IsDead()) return NextActivity;
            var health = target.Trait<Health>();
            if (health.DamageState == DamageState.Undamaged)
                return NextActivity;

            target.InflictDamage(self, -health.MaxHP, null);
            self.Destroy();

            return NextActivity;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:12,代码来源:RepairBuilding.cs


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