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


C# Actor.Kill方法代码示例

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


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

示例1: OnInside

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

				if (cloak != null && cloak.Info.UncloakOnDemolish)
					cloak.Uncloak();

				for (var f = 0; f < flashes; f++)
					w.Add(new DelayedAction(flashesDelay + f * flashInterval, () =>
						w.Add(new FlashTarget(target, ticks: flashDuration))));

				w.Add(new DelayedAction(delay, () =>
				{
					if (target.IsDead)
						return;

					var modifiers = target.TraitsImplementing<IDamageModifier>()
						.Concat(self.Owner.PlayerActor.TraitsImplementing<IDamageModifier>())
						.Select(t => t.GetDamageModifier(self, null));

					if (Util.ApplyPercentageModifiers(100, modifiers) > 0)
						demolishables.Do(d => d.Demolish(target, self));
				}));

				if (enterBehaviour == EnterBehaviour.Suicide)
					self.Kill(self);
				else if (enterBehaviour == EnterBehaviour.Dispose)
					self.Dispose();
			});
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:33,代码来源:Demolish.cs

示例2:

        void INotifyCrushed.OnCrush(Actor self, Actor crusher, HashSet<string> crushClasses)
        {
            if (!CrushableInner(crushClasses, crusher.Owner))
                return;

            Game.Sound.Play(info.CrushSound, crusher.CenterPosition);

            self.Kill(crusher);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:9,代码来源:Crushable.cs

示例3: FindAndTransitionToNextState

        State FindAndTransitionToNextState(Actor self)
        {
            switch (nextState)
            {
                case State.ApproachingOrEntering:

                    // Reserve to enter or approach
                    isEnteringOrInside = false;
                    switch (TryReserveElseTryAlternateReserve(self))
                    {
                        case ReserveStatus.None:
                            return State.Done; // No available target -> abort to next activity
                        case ReserveStatus.TooFar:
                            inner = move.MoveToTarget(self, targetCenter ? Target.FromPos(target.CenterPosition) : target); // Approach
                            return State.ApproachingOrEntering;
                        case ReserveStatus.Pending:
                            return State.ApproachingOrEntering; // Retry next tick
                        case ReserveStatus.Ready:
                            break; // Reserved target -> start entering target
                    }

                    // Entering
                    isEnteringOrInside = true;
                    savedPos = self.CenterPosition; // Save position of self, before entering, for returning on exit

                    inner = move.MoveIntoTarget(self, target); // Enter

                    if (inner != null)
                    {
                        nextState = State.Inside; // Should be inside once inner activity is null
                        return State.ApproachingOrEntering;
                    }

                    // Can enter but there is no activity for it, so go inside without one
                    goto case State.Inside;

                case State.Inside:
                    // Might as well teleport into target if there is no MoveIntoTarget activity
                    if (nextState == State.ApproachingOrEntering)
                        nextState = State.Inside;

                    // Otherwise, try to recover from moving target
                    else if (target.CenterPosition != self.CenterPosition)
                    {
                        nextState = State.ApproachingOrEntering;
                        Unreserve(self, false);
                        if (Reserve(self) == ReserveStatus.Ready)
                        {
                            inner = move.MoveIntoTarget(self, target); // Enter
                            if (inner != null)
                                return State.ApproachingOrEntering;

                            nextState = State.ApproachingOrEntering;
                            goto case State.ApproachingOrEntering;
                        }

                        nextState = State.ApproachingOrEntering;
                        isEnteringOrInside = false;
                        inner = move.MoveIntoWorld(self, self.World.Map.CellContaining(savedPos));

                        return State.ApproachingOrEntering;
                    }

                    OnInside(self);

                    if (enterBehaviour == EnterBehaviour.Suicide)
                        self.Kill(self);
                    else if (enterBehaviour == EnterBehaviour.Dispose)
                        self.Dispose();

                    // Return if Abort(Actor) or Done(self) was called from OnInside.
                    if (nextState >= State.Exiting)
                        return State.Inside;

                    inner = this; // Start inside activity
                    nextState = State.Exiting; // Exit once inner activity is null (unless Done(self) is called)
                    return State.Inside;

                // TODO: Handle target moved while inside or always call done for movable targets and use a separate exit activity
                case State.Exiting:
                    inner = move.MoveIntoWorld(self, self.World.Map.CellContaining(savedPos));

                    // If not successfully exiting, retry on next tick
                    if (inner == null)
                        return State.Exiting;
                    isEnteringOrInside = false;
                    nextState = State.Done;
                    return State.Exiting;

                case State.Done:
                    return State.Done;
            }

            return State.Done; // dummy to quiet dumb compiler
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:95,代码来源:Enter.cs

示例4: Tick

		public override Activity Tick(Actor self)
		{
			if (countdown > 0)
			{
				countdown--;
				return this;
			}

			// Wait for the worm to get back underground
			if (stance == AttackState.ReturningUnderground)
			{
				sandworm.IsAttacking = false;

				// There is a chance that the worm would just go away after attacking
				if (self.World.SharedRandom.Next() % 100 <= sandworm.Info.ChanceToDisappear)
				{
					self.CancelActivity();
					self.World.AddFrameEndTask(w => self.Kill(self));
				}
				else
					withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);

				return NextActivity;
			}

			// Wait for the worm to get in position
			if (stance == AttackState.Burrowed)
			{
				// This is so that the worm cancels an attack against a target that has reached solid rock
				if (!positionable.CanEnterCell(target.Actor.Location, null, false))
					return NextActivity;

				if (!WormAttack(self))
				{
					withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
					return NextActivity;
				}

				countdown = swallow.Info.ReturnTime;
				stance = AttackState.ReturningUnderground;
			}

			return this;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:44,代码来源:SwallowActor.cs

示例5: EditorKillActor

 public void EditorKillActor(Actor actor)
 {
     actors.Remove(actor);
     actor.Kill();
 }
开发者ID:scotttorgeson,项目名称:HeroesOfRock,代码行数:5,代码来源:ActorQB.cs

示例6: Demolish

		public void Demolish(Actor self, Actor saboteur)
		{
			self.Kill(saboteur);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:4,代码来源:Demolishable.cs


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