本文整理汇总了C#中System.Vector3.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Distance方法的具体用法?C# Vector3.Distance怎么用?C# Vector3.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.Distance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AntiTristana
private static void AntiTristana(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
{
if (args.Slot.Equals(SpellSlot.W) && args.End.Distance(Player.Position) <= SpellManager.Q.Range)
{
Vector3 TristPosition = new Vector3();
if (args.End.Distance(args.Start) >= 825)
TristPosition = sender.Position.Extend(args.End, 825);
if (args.Start.Distance(args.End) < 825)
TristPosition = args.End;
if (MenuConfig.AntiTristana && SpellManager.Q.IsReady())
{
if (TristPosition.Distance(Player.Position) <= SpellManager.Q.Range)
{
Utility.DelayAction.Add((int)(500 + Player.Distance(TristPosition) / args.SData.MissileSpeed -
(Player.Distance(TristPosition) / SpellManager.Q.Speed) - 250), () =>
{
if (TristPosition.Distance(Player.Position) < SpellManager.Q.Range)
{
SpellManager.Q.Cast(TristPosition);
}
});
}
}
}
}
示例2: CheckPositionForSkipping
public static bool CheckPositionForSkipping(Vector3 Position)
{
foreach (var v in UsedSkipAheadAreaCache)
{
if (Position.Distance(v.Position) <= v.Radius)
return true;
}
bool valid = false;
if (SkipAheadAreaCache.Count > 0)
{
int validIndex = -1;
for (int i = 0; i < SkipAheadAreaCache.Count - 1; i++)
{
SkipAheadNavigation v = SkipAheadAreaCache[i];
if (Position.Distance(v.Position) <= v.Radius)
{
validIndex = i;
valid = true;
break;
}
}
if (valid && validIndex > 0)
{
UsedSkipAheadAreaCache.Add(SkipAheadAreaCache[validIndex].Clone());
SkipAheadAreaCache.RemoveRange(0, validIndex - 1);
SkipAheadAreaCache.TrimExcess();
}
}
return valid;
}
示例3: Move_Draw
public static void Move_Draw(Vector3 Spell_Start, Vector3 Spell_End, double Spell_Time, int Distance, int Type)
{
if (Spell_Start.Distance(Spell_End) > Distance){var dis = Spell_Start.Distance(Spell_End) - Distance;Spell_End = Spell_End.Extend(Spell_Start, +dis);}
Render.Circle.DrawCircle(Spell_Start, 50, System.Drawing.Color.PaleVioletRed, 1);
Render.Circle.DrawCircle(Spell_End, 50, System.Drawing.Color.LawnGreen, 1);
var from = Drawing.WorldToScreen(Spell_Start);var to = Drawing.WorldToScreen(Spell_End);
Drawing.DrawLine(from[0], from[1], to[0], to[1], 1, System.Drawing.Color.LawnGreen);
Drawing.DrawText(from[0], from[1], System.Drawing.Color.PaleVioletRed, "Start");
Drawing.DrawText(to[0], to[1], System.Drawing.Color.PaleVioletRed, "End");
}
示例4: GetBestObjectFarFrom
public static Obj_AI_Base GetBestObjectFarFrom(Vector3 position)
{
var minion = AllyMinionManager.GetFurthestTo(position);
var ally = AllyHeroManager.GetFurthestTo(position);
var ward = WardManager.GetFurthestTo(position);
var miniondistance = minion != null ? position.Distance(minion, true) : 0;
var allydistance = ally != null ? position.Distance(ally, true) : 0;
var warddistance = ward != null ? position.Distance(ward, true) : 0;
var best = Math.Max(miniondistance, Math.Max(allydistance, warddistance));
if (best > 0f)
{
if (Math.Abs(best - allydistance) < float.Epsilon)
{
return ally;
}
if (Math.Abs(best - miniondistance) < float.Epsilon)
{
return minion;
}
if (Math.Abs(best - warddistance) < float.Epsilon)
{
return ward;
}
}
return null;
}
示例5: MinionCollideLine
public static bool MinionCollideLine(Vector3 lineStart, Vector3 lineFinish, Spell spell)
{
var minion =
MinionManager.GetMinions(spell.Range, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.Health);
// Render.Circle.DrawCircle(ObjectManager.Player.Position, 100, System.Drawing.Color.Brown, 2);
// Render.Circle.DrawCircle(line_finish, 10, System.Drawing.Color.Red, 2);
var d = lineStart.Distance(lineFinish);
// dis = (int)(dis /spell.Width);
var circles = new List<Circle>();
for (var i = 0; i < d; i += 10)
{
var dist = i > d ? d : i;
var point = lineStart.Extend(lineFinish, +dist);
circles.Add(new Circle(point, spell.Width));
}
foreach (var c in circles)
{
foreach (var m in minion)
{
if (Geometry.CircleCircleIntersection(c.pos.To2D(), m.Position.To2D(), c.range, 100).Count()!=0)
{
return true;
}
}
}
// foreach(Obj_AI_Base m in minion)
// {
// m.
// }
// Geometry.cu
return false;
}
示例6: MoveTo
/// <summary>
/// Moves to a world position
/// (naive, blocks execution, avoid using while in combat)
/// </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> MoveTo(Vector3 location, string destinationName = "", float range = 10f, Func<bool> stopCondition = null)
{
var distance = 0f;
var name = string.IsNullOrEmpty(destinationName) ? location.ToString() : destinationName;
Navigator.PlayerMover.MoveTowards(location);
while (ZetaDia.IsInGame && (distance = location.Distance(ZetaDia.Me.Position)) >= range)
{
if (stopCondition != null && stopCondition())
break;
if (ZetaDia.Me.IsDead || Navigator.StuckHandler.IsStuck)
break;
if (Navigation.IsBlocked)
{
Log.Verbose("Movement Failed, It looks like we're blocked!", name, distance);
break;
}
Log.Verbose("Moving to {0} Distance={1}", name, distance);
await Navigator.MoveTo(location, name);
await Coroutine.Yield();
}
if (distance <= range)
Navigator.PlayerMover.MoveStop();
Log.Verbose("MoveTo Finished. Distance={0}", distance);
return true;
}
示例7: MoveTo
private static void MoveTo(Vector3 position, float holdAreaRadius = -1)
{
var delay = 100;
if (Environment.TickCount - _lastMovement < delay)
return;
_lastMovement = Environment.TickCount;
if (!CanMove())
return;
if (player.Position.Distance(position)>50)
player.IssueOrder(GameObjectOrder.MoveTo, position);
return;
if (holdAreaRadius < 0)
holdAreaRadius = 20;
if (player.ServerPosition.Distance(position) < holdAreaRadius)
{
if (player.Path.Count() > 1)
player.IssueOrder(GameObjectOrder.HoldPosition, player.ServerPosition);
return;
}
if (position.Distance(player.Position) < 200)
player.IssueOrder(GameObjectOrder.MoveTo, position);
else
{
var point = player.ServerPosition +
200 * (position.To2D() - player.ServerPosition.To2D()).Normalized().To3D();
player.IssueOrder(GameObjectOrder.MoveTo, point);
}
}
示例8: EngageFriendLatern
private void EngageFriendLatern()
{
if(!W.IsReady())
return;
var bestcastposition = new Vector3(0f, 0f, 0f);
foreach(var friend in PUC.AllHerosFriend.Where(hero => !hero.IsMe && hero.Distance(PUC.Player) <= W.Range + 300 && hero.Distance(PUC.Player) <= W.Range - 300 && hero.Health / hero.MaxHealth * 100 >= 20 && EnemysinRange(150)))
{
var center = PUC.Player.Position;
const int points = 36;
var radius = W.Range;
const double slice = 2 * Math.PI / points;
for(var i = 0; i < points; i++)
{
var angle = slice * i;
var newX = (int)(center.X + radius * Math.Cos(angle));
var newY = (int)(center.Y + radius * Math.Sin(angle));
var p = new Vector3(newX, newY, 0);
if(p.Distance(friend.Position) <= bestcastposition.Distance(friend.Position))
bestcastposition = friend.Position;
}
if(!(friend.Distance(PUC.Player) <= W.Range))
continue;
W.Cast(bestcastposition, UsePackets());
return;
}
if(bestcastposition.Distance(new Vector3(0f, 0f, 0f)) >= 100)
W.Cast(bestcastposition, UsePackets());
}
示例9: PingGround
private static void PingGround(Vector3 point, PingCategory pingtype)
{
if (point.Distance(ObjectManager.Player.ServerPosition) > 1000) return;
if (Utils.GameTimeTickCount - LastPing < Rand.Next(100, 1100) || NumberOfPings >= Rand.Next(Math.Max(1, Config.Item("maxpings").GetValue<Slider>().Value/2), Config.Item("maxpings").GetValue<Slider>().Value)) return;
LastPing = Utils.GameTimeTickCount;
NumberOfPings++;
Game.SendPing(pingtype, point);
}
示例10: PingGround
private static void PingGround(Vector3 point, PingCategory pingtype)
{
if (point.Distance(Player.Instance.ServerPosition) > 1000) return;
if (Environment.TickCount - LastPing < Rnd.Next(100, 1100) || NumberOfPings >= Rnd.Next(Math.Max(1, Config["maxpings"].Cast<Slider>().CurrentValue / 2), Config["maxpings"].Cast<Slider>().CurrentValue)) return;
LastPing = Environment.TickCount;
NumberOfPings++;
TacticalMap.SendPing(pingtype, point);
}
示例11: CastSpell
static bool CastSpell(Vector3 lanternPos)
{
if (Spell != null && Spell.IsReady() && lanternPos.Distance(Player.ServerPosition) <= Spell.Range)
{
Console.WriteLine("Cast spell to lantern");
Spell.Cast(lanternPos);
return true;
}
return false;
}
示例12: GetFirstWallPoint
public Vector3 GetFirstWallPoint(Vector3 start, Vector3 end, float range)
{
if (end.IsValid() && start.Distance(end) <= range)
{
var newPoint = start.Extend(end, range);
return NavMesh.GetCollisionFlags(newPoint) == CollisionFlags.Wall || newPoint.IsWall()
? newPoint
: Vector3.Zero;
}
return Vector3.Zero;
}
示例13: GetTarget
//my condemn logic so far
public static Obj_AI_Base GetTarget(Vector3 fromPosition)
{
var targetList =
EntityManager.Heroes.Enemies.Where(
h =>
h.IsValidTarget(Manager.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 = Manager.SpellManager.E2.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 < Manager.MenuManager.CondemnPushDistance; i += (int)enemy.BoundingRadius)
{
var finalPosition = fromPosition.Extend(position, distance + i).To3D();
var j4Flag = Manager.MenuManager.J4Flag && (Variables.IsJ4Flag(finalPosition, enemy));
if (NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Wall)
|| NavMesh.GetCollisionFlags(finalPosition).HasFlag(CollisionFlags.Building) || j4Flag)
{
wallsFound++;
break;
}
}
}
if (wallsFound >= Manager.MenuManager.CondemnHitchance)
{
return enemy;
}
}
return null;
}
示例14: CountEnemiesInRangeDeley
public static int CountEnemiesInRangeDeley(Vector3 position, float range, float delay)
{
int count = 0;
foreach (var t in HeroManager.Enemies.Where(t => t.IsValidTarget()))
{
Vector3 prepos = Prediction.GetPrediction(t, delay).CastPosition;
if (position.Distance(prepos) < range)
count++;
}
return count;
}
示例15: CountEnemies
public static int CountEnemies(Vector3 from, float Range, GameObjectTeam team)
{
int Counter = 0;
List<Obj_AI_Hero> Enemies = null;
Enemies = ObjectHandler.Get<Obj_AI_Hero>().Where(t => t.IsEnemy && !t.IsDead).ToList();
foreach (Obj_AI_Hero hero in Enemies)
{
if (from.Distance(hero.Position) < Range)
{
Counter++;
}
}
return Counter;
}