本文整理匯總了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;
}