本文整理汇总了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();
});
}
示例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);
}
示例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
}
示例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;
}
示例5: EditorKillActor
public void EditorKillActor(Actor actor)
{
actors.Remove(actor);
actor.Kill();
}
示例6: Demolish
public void Demolish(Actor self, Actor saboteur)
{
self.Kill(saboteur);
}