本文整理汇总了C#中Mooege.Core.GS.Map.World.GetActorByDynamicId方法的典型用法代码示例。如果您正苦于以下问题:C# World.GetActorByDynamicId方法的具体用法?C# World.GetActorByDynamicId怎么用?C# World.GetActorByDynamicId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mooege.Core.GS.Map.World
的用法示例。
在下文中一共展示了World.GetActorByDynamicId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNearestTarget
// get nearest target of targetType
public static Actor GetNearestTarget(World world, Actor attacker, Vector3D centerPosition, float range, ActorType targetType = ActorType.Monster)
{
Actor result = null;
List<Actor> actors = world.QuadTree.Query<Actor>(new Circle(centerPosition.X, centerPosition.Y, range));
if (actors.Count > 1)
{
float distanceNearest = range; // max. range
float distance = 0f;
foreach (var target in actors.Where(target => ((target.ActorType == targetType) && (target != attacker) && !target.Attributes[GameAttribute.Is_NPC])))
{
if ((target.World == null) || (world.GetActorByDynamicId(target.DynamicID) == null))
{
// leaving world
continue;
}
distance = ActorUtils.GetDistance(centerPosition, target.Position);
if ((result == null) || (distance < distanceNearest))
{
result = target;
distanceNearest = distance;
}
}
}
return result;
}