當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。