本文整理汇总了C#中Actor.GetCurrentActivity方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.GetCurrentActivity方法的具体用法?C# Actor.GetCurrentActivity怎么用?C# Actor.GetCurrentActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.GetCurrentActivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseMoveAnim
bool ChooseMoveAnim(Actor self)
{
if (!(self.GetCurrentActivity() is Move) && !(self.GetCurrentActivity() is Drag)) // A bit of a hack
return false;
var mobile = self.Trait<Mobile>();
if (float2.WithinEpsilon(self.CenterLocation, Util.CenterOfCell(mobile.toCell), 2)) return false;
var seq = IsProne(self) ? "crawl" : "run";
if (anim.CurrentSequence.Name != seq)
anim.PlayRepeating(seq);
return true;
}
示例2: GetCurrentPath
public override IEnumerable<float2> GetCurrentPath(Actor self)
{
var move = self.GetCurrentActivity() as Activities.HeliFly;
if (move == null) return new float2[] { };
return new float2[] { move.Dest };
}
示例3: TextRenderable
IEnumerable<IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr)
{
if (devMode == null || !devMode.ShowActorTags)
yield break;
yield return new TextRenderable(font, self.CenterPosition - offset, 0, color, tagString);
// Get the actor's activity.
var activity = self.GetCurrentActivity();
if (activity != null)
{
var activityName = activity.GetType().ToString().Split('.').Last();
yield return new TextRenderable(font, self.CenterPosition, 0, color, activityName);
}
// Get the AI squad that this actor belongs to.
if (!self.Owner.IsBot)
yield break;
if (ai == null)
yield break;
var squads = ai.Squads;
var squad = squads.FirstOrDefault(x => x.Units.Contains(self));
if (squad == null)
yield break;
var aiSquadInfo = "{0}, {1}".F(squad.Type, squad.TargetActor);
yield return new TextRenderable(font, self.CenterPosition + offset, 0, color, aiSquadInfo);
}
示例4: BusyAttack
protected static bool BusyAttack(Actor a)
{
if (a.IsIdle)
return false;
var type = a.GetCurrentActivity().GetType();
if (type == typeof(Attack) || type == typeof(FlyAttack))
return true;
var next = a.GetCurrentActivity().NextActivity;
if (next == null)
return false;
var nextType = a.GetCurrentActivity().NextActivity.GetType();
if (nextType == typeof(Attack) || nextType == typeof(FlyAttack))
return true;
return false;
}
示例5: Tick
public override void Tick(Actor self)
{
var isAttacking = self.GetCurrentActivity() is Attack;
var attack = self.TraitOrDefault<AttackBase>();
if (attack != null)
anim.ReplaceAnim((attack.IsReloading() ? "empty-" : "")
+ (isAttacking ? "aim" : "idle"));
base.Tick(self);
}
示例6: Tick
public override void Tick(Actor self)
{
base.Tick(self);
if (inAttack) return;
if (self.GetCurrentActivity() is Activities.IdleAnimation) return;
if (ChooseMoveAnim(self)) return;
if (IsProne(self))
anim.PlayFetchIndex("crawl", () => 0); /* what a hack. */
else
anim.Play("stand");
}
示例7: Tick
public override void Tick(Actor self)
{
base.Tick(self);
if (!target.IsValid) return;
if (self.GetCurrentActivity() is Leap) return;
var weapon = self.Trait<AttackBase>().Weapons[0].Info;
if (weapon.Range * Game.CellSize * weapon.Range * Game.CellSize
< (target.CenterLocation - self.CenterLocation).LengthSquared) return;
self.CancelActivity();
self.QueueActivity(new Leap(self, target));
}
示例8: IsRearm
protected static bool IsRearm(Actor a)
{
var activity = a.GetCurrentActivity();
if (activity == null)
return false;
var type = activity.GetType();
if (type == typeof(Rearm) || type == typeof(ResupplyAircraft))
return true;
var next = activity.NextActivity;
if (next == null)
return false;
var nextType = next.GetType();
if (nextType == typeof(Rearm) || nextType == typeof(ResupplyAircraft))
return true;
return false;
}
示例9: OnNotifyBlockingMove
public void OnNotifyBlockingMove(Actor self, Actor blocking)
{
// I'm blocking someone else from moving to my location:
var act = self.GetCurrentActivity();
// If I'm just waiting around then get out of the way:
if (act is Wait)
{
self.CancelActivity();
var mobile = self.Trait<Mobile>();
var cell = self.Location;
var moveTo = mobile.NearestMoveableCell(cell, 2, 5);
self.QueueActivity(mobile.MoveTo(moveTo, 0));
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
// Find more resources but not at this location:
self.QueueActivity(new FindResources(cell));
}
}
示例10: GetCurrentPath
public IEnumerable<float2> GetCurrentPath(Actor self)
{
var move = self.GetCurrentActivity() as Move;
if (move == null || move.path == null) return new float2[] { };
return Enumerable.Reverse(move.path).Select( c => Util.CenterOfCell(c) );
}
示例11: ActivityTargetPath
IEnumerable<WPos> ActivityTargetPath(Actor self)
{
if (!self.IsInWorld || self.IsDead)
yield break;
var activity = self.GetCurrentActivity();
if (activity != null)
{
var targets = activity.GetTargets(self);
yield return self.CenterPosition;
foreach (var t in targets.Where(t => t.Type != TargetType.Invalid))
yield return t.CenterPosition;
}
}
示例12: DrawUnitPath
void DrawUnitPath(WorldRenderer wr, Actor self)
{
if (self.World.LocalPlayer == null ||!self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug) return;
var activity = self.GetCurrentActivity();
if (activity != null)
{
var targets = activity.GetTargets(self);
var start = wr.ScreenPxPosition(self.CenterPosition);
var c = Color.Green;
var wlr = Game.Renderer.WorldLineRenderer;
foreach (var stp in targets.Where(t => t.Type != TargetType.Invalid).Select(p => wr.ScreenPxPosition(p.CenterPosition)))
{
wlr.DrawLine(stp + new float2(-1, -1), stp + new float2(-1, 1), c, c);
wlr.DrawLine(stp + new float2(-1, 1), stp + new float2(1, 1), c, c);
wlr.DrawLine(stp + new float2(1, 1), stp + new float2(1, -1), c, c);
wlr.DrawLine(stp + new float2(1, -1), stp + new float2(-1, -1), c, c);
wlr.DrawLine(start, stp, c, c);
start = stp;
}
}
}
示例13: Damaged
public void Damaged(Actor self, AttackInfo e)
{
if (self.GetCurrentActivity() is Activities.IdleAnimation)
self.CancelActivity();
}
示例14: DrawUnitPath
void DrawUnitPath(Actor self)
{
if (self.World.LocalPlayer == null ||!self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug) return;
var activity = self.GetCurrentActivity();
var mobile = self.TraitOrDefault<IMove>();
if (activity != null && mobile != null)
{
var alt = new float2(0, -mobile.Altitude);
var targets = activity.GetTargets(self);
var start = self.CenterLocation.ToFloat2() + alt;
var c = Color.Green;
var wlr = Game.Renderer.WorldLineRenderer;
foreach (var step in targets.Select(p => p.CenterLocation.ToFloat2()))
{
var stp = step + alt;
wlr.DrawLine(stp + new float2(-1, -1), stp + new float2(-1, 1), c, c);
wlr.DrawLine(stp + new float2(-1, 1), stp + new float2(1, 1), c, c);
wlr.DrawLine(stp + new float2(1, 1), stp + new float2(1, -1), c, c);
wlr.DrawLine(stp + new float2(1, -1), stp + new float2(-1, -1), c, c);
wlr.DrawLine(start, stp, c, c);
start = stp;
}
}
}
示例15: GetCurrentPath
public virtual IEnumerable<float2> GetCurrentPath(Actor self)
{
var move = self.GetCurrentActivity() as Activities.Fly;
if (move == null) return new float2[] { };
return new float2[] { move.Pos };
}