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


C# Actor.IsDead方法代码示例

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


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

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

示例2: Tick

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

            if (transport == null || !transport.IsInWorld)
                return NextActivity;

            if (!cargo.CanLoad(transport, self))
                return NextActivity;

            // TODO: Queue a move order to the transport? need to be
            // careful about units that can't path to the transport
            var cells = Util.AdjacentCells(Target.FromActor(transport));
            if (!cells.Contains(self.Location))
                return NextActivity;

            self.World.AddFrameEndTask(w =>
            {
                if (self.IsDead() || transport.IsDead() || !cargo.CanLoad(transport, self))
                    return;

                cargo.Load(transport, self);
                w.Remove(self);
            });

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

示例3: Tick

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

            if (started)
            {
                // Don't break the actor if someone has overriden the animation prematurely
                if (rb.anim.CurrentSequence.Name != "make")
                {
                    complete = true;
                    OnComplete();
                }
                return complete ? NextActivity : this;
            }

            started = true;
            rb = self.Trait<RenderBuilding>();
            if (Reversed)
            {
                // TODO: These don't belong here
                var bi = self.Info.Traits.GetOrDefault<BuildingInfo>();
                if (bi != null)
                    foreach (var s in bi.SellSounds)
                        Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);

                rb.PlayCustomAnimBackwards(self, "make", () => { OnComplete(); complete = true;});
            }
            else
                rb.PlayCustomAnimThen(self, "make", () => { OnComplete(); complete = true;});

            return this;
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:33,代码来源:MakeAnimation.cs

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

示例5: 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:RobotCaleb,项目名称:OpenRA,代码行数:58,代码来源:ExternalCaptureActor.cs

示例6: Tick

        public override void Tick(Actor self)
        {
            base.Tick(self);

            var isFlying = self.Trait<IMove>().Altitude > 0 && !self.IsDead();
            if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor"))
                return;

            rotorAnim.ReplaceAnim(isFlying ? "rotor" : "slow-rotor");
            if (secondRotorAnim != null)
                secondRotorAnim.ReplaceAnim(isFlying ? "rotor2" : "slow-rotor2");
        }
开发者ID:djohe,项目名称:OpenRA,代码行数:12,代码来源:RenderUnitRotor.cs

示例7: OnInside

        protected override void OnInside(Actor self)
        {
            self.World.AddFrameEndTask(w =>
            {
                if (self.IsDead() || transport.IsDead() || !cargo.CanLoad(transport, self))
                    return;

                cargo.Load(transport, self);
                w.Remove(self);
            });

            Done(self);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:13,代码来源:EnterTransport.cs

示例8: Produce

		public override bool Produce(Actor self, ActorInfo producee, string raceVariant)
		{
			var owner = self.Owner;

			// Start a fixed distance away: the width of the map.
			// This makes the production timing independent of spawnpoint
			var startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
			var endPos = new CPos(owner.World.Map.Bounds.Left - 5, self.Location.Y);

			// Assume a single exit point for simplicity
			var exit = self.Info.Traits.WithInterface<ExitInfo>().First();

			foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
				tower.IncomingDelivery(self);

			var info = (ProductionAirdropInfo)Info;
			var actorType = info.ActorType;

			owner.World.AddFrameEndTask(w =>
			{
				var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get<PlaneInfo>().CruiseAltitude;
				var a = w.CreateActor(actorType, new TypeDictionary
				{
					new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)),
					new OwnerInit(owner),
					new FacingInit(64)
				});

				a.QueueActivity(new Fly(a, Target.FromCell(w, self.Location + new CVec(9, 0))));
				a.QueueActivity(new Land(Target.FromActor(self)));
				a.QueueActivity(new CallFunc(() =>
				{
					if (!self.IsInWorld || self.IsDead())
						return;

					foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
						cargo.Delivered(self);

					self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit, raceVariant));
					Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Country.Race);
				}));

				a.QueueActivity(new Fly(a, Target.FromCell(w, endPos)));
				a.QueueActivity(new RemoveSelf());
			});

			return true;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:48,代码来源:ProductionAirdrop.cs

示例9: Produce

        public override bool Produce( Actor self, ActorInfo producee )
        {
            var owner = self.Owner;

            // Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
            var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width+5, self.Location.Y);
            var endPos = new int2(owner.World.Map.XOffset-5, self.Location.Y);

            // Assume a single exit point for simplicity
            var spawn = self.CenterLocation + Spawns.First().First;
            var exit = self.Location + Spawns.First().Second;

            owner.World.AddFrameEndTask(w =>
            {
                var a = w.CreateActor("C17", new TypeDictionary
                {
                    new LocationInit( startPos ),
                    new OwnerInit( owner ),
                    new FacingInit( 64 ),
                    new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
                });

                var cargo = a.Trait<Cargo>();
                var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
                {
                    new OwnerInit( self.Owner ),
                });
                cargo.Load(a, newUnit);

                a.QueueActivity(new Land(Target.FromActor(self)));
                a.QueueActivity(new CallFunc(() =>
                {
                    if (self.IsDead())
                        return;
                    self.World.AddFrameEndTask(ww => DoProduction(self, cargo.Unload(self), exit, spawn));
                }));
                a.QueueActivity(new Fly(endPos));
                a.QueueActivity(new RemoveSelf());
            });

            return true;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:42,代码来源:ProductionAirdrop.cs

示例10: Produce

        public override bool Produce( Actor self, ActorInfo producee )
        {
            var owner = self.Owner;

            // Start a fixed distance away: the width of the map.
            // This makes the production timing indepent of spawnpoint
            var startPos = self.Location + new int2(owner.World.Map.Bounds.Width, 0);
            var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);

            // Assume a single exit point for simplicity
            var exit = self.Info.Traits.WithInterface<ExitInfo>().First();

            var rb = self.Trait<RenderBuilding>();
            rb.PlayCustomAnimRepeating(self, "active");
            owner.World.AddFrameEndTask(w =>
            {
                var a = w.CreateActor("C17", new TypeDictionary
                {
                    new LocationInit( startPos ),
                    new OwnerInit( owner ),
                    new FacingInit( 64 ),
                    new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
                });

                a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
                a.QueueActivity(new Land(Target.FromActor(self)));
                a.QueueActivity(new CallFunc(() =>
                {
                    if (!self.IsInWorld || self.IsDead())
                        return;

                    rb.PlayCustomAnimRepeating(self, "idle");
                    self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
                    Sound.PlayToPlayer(self.Owner, (Info as ProductionAirdropInfo).ReadyAudio);
                }));
                a.QueueActivity(Fly.ToCell(endPos));
                a.QueueActivity(new RemoveSelf());
            });

            return true;
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:41,代码来源:ProductionAirdrop.cs

示例11: Produce

        public override bool Produce( Actor self, ActorInfo producee )
        {
            var owner = self.Owner;

            // Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
            var startPos = new int2(owner.World.Map.Bounds.Right + 5, self.Location.Y);
            var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);

            // Assume a single exit point for simplicity
            var exit = self.Info.Traits.WithInterface<ExitInfo>().First();

            var rb = self.Trait<RenderBuilding>();
            rb.PlayCustomAnimRepeating(self, "active");
            owner.World.AddFrameEndTask(w =>
            {
                var a = w.CreateActor("C17", new TypeDictionary
                {
                    new LocationInit( startPos ),
                    new OwnerInit( owner ),
                    new FacingInit( 64 ),
                    new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
                });

                a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
                a.QueueActivity(new Land(Target.FromActor(self)));
                a.QueueActivity(new CallFunc(() =>
                {
                    if (!self.IsInWorld || self.IsDead())
                        return;

                    rb.PlayCustomAnimRepeating(self, "idle");
                    self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
                }));
                a.QueueActivity(Fly.ToCell(endPos));
                a.QueueActivity(new RemoveSelf());
            });

            return true;
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:39,代码来源:ProductionAirdrop.cs

示例12: Update

 public void Update(Actor self, IOccupySpace unit)
 {
     Remove(self, unit);
     if (!self.IsDead()) Add(self, unit);
 }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:5,代码来源:UnitInfluence.cs

示例13: Damaged

 public void Damaged(Actor self, AttackInfo e)
 {
     if (self.IsDead())
         Player.TakeOre(Stored);	// Lose the stored ore
 }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:5,代码来源:StoresOre.cs

示例14: Tick

        public override void Tick()
        {
            if (members.Count() == 0) return;

            // Check if enemy unit is nearby
            if (AI.ticks % 25 == 0)
            {
                Actor leader = members.First();
                if (leader == null || leader.IsDead() || leader.Destroyed) return;

                var EnemyUnits = world.FindUnitsInCircle(leader.CenterLocation, 120)
                    .Where(a => AI.p.Stances[a.Owner] == Stance.Enemy);

                if (EnemyUnits != null && EnemyUnits.Count() != 0)
                {
                    EnemyNearby = true;
                    OnEnemyUnitsNearby(EnemyUnits);
                }
                else
                {
                    EnemyNearby = false;
                }
            }

            if (AI.ticks % 75 == 0 && !EnemyNearby)
            {
                if (IsReady() && squadrole == SquadRole.AttackBase) // we're ready to attack
                {
                    // if we have a target update our move-to location
                    if (Target != null && !Target.IsDead() && !Target.Destroyed)
                    {
                        CPos Location = Target.Location;
                        Move(Location, false, 8);
                    }
                    else // if we don't have a target find one
                    {
                        Target = AI.ChooseEnemyTarget("sub");
                        if (Target == null || Target.IsDead() || Target.Destroyed)
                        {
                            Target = null;
                            AI.Debug("ShipSquad: Target is null.");
                            return;
                        }
                        CPos Location = Target.Location;
                        Move(Location, false, 8);
                    }
                }
                if (!IsReady()) // While we're not ready check if squad is full, if it is set us to ready
                {
                    isready = IsFull();
                }
            }
        }
开发者ID:Iran,项目名称:ClassicRA,代码行数:53,代码来源:ShipSquad.cs

示例15: Damaged

 public void Damaged(Actor self, AttackInfo e)
 {
     if (self.IsDead() && Player.GetSiloFullness() > 0)
         Player.TakeOre(Stored(self));		// Lose the stored ore
 }
开发者ID:subspace,项目名称:OpenRA,代码行数:5,代码来源:StoresOre.cs


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