本文整理汇总了C#中Vector3.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Distance方法的具体用法?C# Vector3.Distance怎么用?C# Vector3.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Distance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckWallCollison
public static bool CheckWallCollison(this AIHeroClient player, Vector3 targetpos)
{
for (int i = 0; i < targetpos.Distance(player.Position); i += 30)
{
Vector3 wallPosition = targetpos.ExtendVector3(player.Position, targetpos.Distance(player.Position) - i);
if (NavMesh.GetCollisionFlags(wallPosition).HasFlag(CollisionFlags.Wall) || NavMesh.GetCollisionFlags(wallPosition).HasFlag(CollisionFlags.Building))
return true;
}
return false;
}
示例2: Execute
/// <summary>
/// Moves to somewhere.
/// </summary>
/// <param name="location">where to move to</param>
/// <param name="destinationName">name of location for debugging purposes</param>
/// <param name="range">how close it should get</param>
public static async Task<bool> Execute(Vector3 location, string destinationName = "", float range = 10f)
{
while (ZetaDia.IsInGame && location.Distance(ZetaDia.Me.Position) >= range)
{
Logger.LogVerbose("Moving to " + destinationName);
PlayerMover.NavigateTo(location, destinationName);
await Coroutine.Yield();
}
var distance = location.Distance(ZetaDia.Me.Position);
if (distance <= range)
Navigator.PlayerMover.MoveStop();
Logger.LogVerbose("MoveTo Finished. Distance={0}", distance);
return true;
}
示例3: GetBestPosition
public static Vector3 GetBestPosition(Obj_AI_Hero target, Vector3 firstPosition, Vector3 secondPosition)
{
if (firstPosition.IsWall() && !secondPosition.IsWall() &&
secondPosition.Distance(target.ServerPosition) < firstPosition.Distance(target.ServerPosition))
// if firstposition is a wall and second position isn't
{
return secondPosition; //return second position
}
if (secondPosition.IsWall() && !firstPosition.IsWall() &&
firstPosition.Distance(target.ServerPosition) < secondPosition.Distance(target.ServerPosition))
// if secondPosition is a wall and first position isn't
{
return firstPosition; // return first position
}
return firstPosition;
}
示例4: GetNearestSoldierToMouse
public static GameObject GetNearestSoldierToMouse(Vector3 pos)
{
var soldier = Orbwalker.AzirSoldiers.ToList().OrderBy(x => pos.Distance(x.Position));
if (soldier.FirstOrDefault() != null)
return soldier.FirstOrDefault();
return null;
}
示例5: GetTarget
public static Obj_AI_Base GetTarget(Vector3 fromPosition)
{
var targetList =
EntityManager.Heroes.Enemies.Where(
h =>
h.IsValidTarget(SpellManager.E.Range) && !h.HasBuffOfType(BuffType.SpellShield)
&& !h.HasBuffOfType(BuffType.SpellImmunity)
&& h.Health > ObjectManager.Player.GetAutoAttackDamage(h, true) * 2).ToList();
if (!targetList.Any())
{
return null;
}
foreach (var enemy in targetList)
{
var prediction = SpellManager.E.GetPrediction(enemy);
var predictionsList = new List<Vector3>
{
enemy.ServerPosition,
enemy.Position,
prediction.CastPosition,
prediction.UnitPosition
};
var wallsFound = 0;
foreach (var position in predictionsList)
{
var distance = fromPosition.Distance(position);
for (var i = 0; i < Config.Settings.Condemn.PushDistance; i += (int)enemy.BoundingRadius)
{
var finalPosition = fromPosition.Extend(position, distance + i).To3D();
if (NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Wall)
|| NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Building))
{
wallsFound++;
break;
}
}
}
if (wallsFound >= Config.Settings.Condemn.Accuracy)
{
return enemy;
}
}
return null;
}
示例6: Execute
/// <summary>
/// Moves to a position, finds actor by Id and interacts with it
/// </summary>
/// <param name="actorId">id of actor to interact with</param>
/// <param name="range">how close to get</param>
/// <param name="position">position from which to interact</param>
/// <param name="interactLimit">maximum number of times to interact</param>
public static async Task<bool> Execute(Vector3 position, int actorId, float range = -1f, int interactLimit = 5)
{
if (position == Vector3.Zero)
return false;
if (interactLimit < 1) interactLimit = 5;
if (range < 0) range = 2f;
if (position.Distance(ZetaDia.Me.Position) > range)
{
if (!await MoveTo.Execute(position, position.ToString()))
{
Logger.Log("MoveTo Failed for {0} Distance={1}", position, position.Distance(ZetaDia.Me.Position));
return false;
}
}
var actor = ZetaDia.Actors.GetActorsOfType<DiaObject>(true).FirstOrDefault(a => a.ActorSNO == actorId);
if (actor == null)
{
Logger.LogVerbose("Interaction Failed: Actor not found with Id={0}", actorId);
return false;
}
var distance = position.Distance(ZetaDia.Me.Position);
if (distance <= range || distance - actor.CollisionSphere.Radius <= range)
{
for (int i = 1; i <= interactLimit; i++)
{
Logger.Log("Interacting with {0} ({1}) Attempt={2}", actor.Name, actor.ActorSNO, i);
if (actor.Interact() && i > 1)
break;
await Coroutine.Sleep(100);
await Coroutine.Yield();
}
}
// Better to be redundant than failing to interact.
Navigator.PlayerMover.MoveTowards(actor.Position);
await Coroutine.Sleep(250);
actor.Interact();
Navigator.PlayerMover.MoveStop();
await Coroutine.Sleep(1000);
await Interact(actor);
return true;
}
示例7: GetFirstWallPoint
public static Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, int step = 1)
{
if (start.IsValid() && end.IsValid())
{
var distance = start.Distance(end);
for (var i = 0; i < distance; i = i + step)
{
var newPoint = start.Extend(end, i);
if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall())
{
return newPoint;
}
}
}
return Vector3.Zero;
}
示例8: FirstWallPoint
/// <summary>
/// Gets the first wall point/node, w/e.
/// </summary>
/// <param name="playerPosition"></param>
/// <param name="endPosition"></param>
/// <param name="step"></param>
/// <returns></returns>
public Vector3 FirstWallPoint(Vector3 playerPosition, Vector3 endPosition, int step = 1)
{
if (!playerPosition.IsValid() || !endPosition.IsValid())
{
return Vector3.Zero;
}
var distance = playerPosition.Distance(endPosition);
for (var i = 0; i < distance; i = i + step)
{
var newPoint = playerPosition.Extend(endPosition, i);
if (NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall())
{
return newPoint;
}
}
return Vector3.Zero;
}
示例9: AnyWallInBetween
/// <summary>
/// Returns true if there is a Wall between X pos and Y pos.
/// </summary>
public static bool AnyWallInBetween(Vector3 startPos, Vector3 endPos)
{
for (var i = 0; i < startPos.Distance(endPos); i++)
{
if (NavMesh.GetCollisionFlags(startPos.Extend(endPos, i)) == CollisionFlags.Wall)
{
return true;
}
}
return false;
}
示例10: JinxTrap
public static bool JinxTrap(Vector3 castposition)
{
return
ObjectManager.Get<Obj_AI_Base>()
.Where(a => a.BaseSkinName == "JinxMine").Any(a => castposition.Distance(a.Position) <= 300);
}
示例11: CaitTrap
public static bool CaitTrap(Vector3 castposition)
{
return
ObjectManager.Get<Obj_AI_Base>()
.Where(a => a.BaseSkinName == "CaitlynTrap").Any(a => castposition.Distance(a.Position) <= 250);
}
示例12: UnderEnemyTurret
public static bool UnderEnemyTurret(Vector3 pos)
{
return ObjectManager.Get<Obj_AI_Turret>().Any(t => t.IsEnemy && !t.IsDead && pos.Distance(t) <= 900);
}
示例13: InSpawnPoint
public static bool InSpawnPoint(Vector3 pos)
{
return ObjectManager.Get<Obj_SpawnPoint>().Any(x => pos.Distance(x) < 800 && x.IsEnemy);
}
示例14: InAARange
public bool InAARange(Vector3 point)
{
if (!getCheckBoxItem("AAcheck"))
return true;
if (Orbwalker.LastTarget != null && Orbwalker.LastTarget.Type == GameObjectType.AIHeroClient)
{
return point.Distance(Orbwalker.LastTarget.Position) < Player.AttackRange;
}
return point.CountEnemiesInRange(Player.AttackRange) > 0;
}
示例15: Shroomed
private static bool Shroomed(Vector3 castposition)
{
return
ObjectManager.Get<Obj_AI_Minion>()
.Where(a => a.Name == "Noxious Trap").Any(a => castposition.Distance(a.Position) <= 300);
}