本文整理汇总了C#中SharpDX.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# SharpDX.Distance方法的具体用法?C# SharpDX.Distance怎么用?C# SharpDX.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpDX
的用法示例。
在下文中一共展示了SharpDX.Distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveToPosWithNavMeshAsync
public static async Task<bool> MoveToPosWithNavMeshAsync(SharpDX.Vector3 vecDest, int NearDistance = 50)
{
if (Nav.D3.Navmesh.Current == null)
Nav.D3.Navmesh.Create(Enigma.D3.Engine.Current, new Nav.ExploreEngine.Nearest());
var localAcd = ActorCommonDataHelper.GetLocalAcd();
var distance = vecDest.Distance(); // (Math.Pow(localAcd.x0D0_WorldPosX - vecDest.X, 2) + Math.Pow(localAcd.x0D4_WorldPosY - vecDest.Y, 2));
var minDistanceReached = distance;
var dtDistanceReached = DateTime.Now;
DateTime dtTimeout = DateTime.Now;
while (distance > NearDistance)
{
if (DateTime.Now > dtTimeout.AddSeconds(30) || DateTime.Now > dtDistanceReached.AddSeconds(10))
return false;
SharpDX.Vector2 curVector = localAcd.ToSharpDXVector2(); // new SharpDX.Vector2(localAcd.x0D0_WorldPosX, localAcd.x0D4_WorldPosY);
SharpDX.Vector2 destVector = new SharpDX.Vector2(vecDest.X, vecDest.Y);
// Update current player position.
Nav.D3.Navmesh.Current.Navigator.CurrentPos = localAcd.ToNavVec3(); // new Nav.Vec3(localAcd.x0D0_WorldPosX, localAcd.x0D4_WorldPosY, localAcd.x0D8_WorldPosZ);
// Update destination. You can keep setting the same value there is internal check if destination has actually changed.
// This destination overrides any internal destinations (including exploration). When You just want to explore You do
// not need to set any destination. It will be set automatically.
Nav.D3.Navmesh.Current.Navigator.Destination = new Nav.Vec3(vecDest.X, vecDest.Y, vecDest.Z);
// Get current destination.
Nav.Vec3 goToPosition = Nav.D3.Navmesh.Current.Navigator.GoToPosition;
while (goToPosition.IsEmpty)
await Task.Delay(10);
SharpDX.Vector3 goToPositionVector = new SharpDX.Vector3(goToPosition.X, goToPosition.Y, goToPosition.Z);
await MoveToPosAsync(goToPositionVector);
}
return true;
}
示例2: HitCount
internal static int HitCount(float delay, float range, SharpDX.Vector3 sourcePosition)
{
byte hitcount = 0;
foreach (var enemy in HeroManager.Enemies.Where(x => x.IsValidTarget(range, false, sourcePosition)))
{
var pred = Prediction.GetPrediction(enemy, delay);
if (sourcePosition.Distance(pred.UnitPosition) <= range)
hitcount++;
}
return hitcount;
}