本文整理汇总了C#中WoWPoint.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# WoWPoint.Distance方法的具体用法?C# WoWPoint.Distance怎么用?C# WoWPoint.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WoWPoint
的用法示例。
在下文中一共展示了WoWPoint.Distance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: movetoLoc
public static void movetoLoc(WoWPoint loc)
{
while (loc.Distance(Me.Location) > 10)
{
Navigator.MoveTo(loc);
Thread.Sleep(100);
if (inCombat) return;
}
Thread.Sleep(2000);
}
示例2: CountOfAddsInRange
public static int CountOfAddsInRange(double distance, WoWPoint location)
{
List<WoWUnit> hlist =
(from o in ObjectManager.ObjectList
where o is WoWUnit
let p = o.ToUnit()
where p.Distance2D < 40
&& !p.Dead
&& p.Combat
&& (p.IsTargetingMyPartyMember || p.IsTargetingMeOrPet)
&& p.IsHostile
&& p.Attackable
select p).ToList();
return hlist.Count(u => location.Distance(u.Location) <= distance);
}
示例3: GetUnstuck
public static void GetUnstuck()
{
PriorityTreeState.StuckTimer.Reset();
//PickPocketTarget.AddToStuckBlacklist();
Enemy.ClearAllTargetData();
WoWPoint myNewWoWPoint;
do {
float x, y, z;
do {
x = StyxWoW.Me.Location.X + RandomNumber.GenerateRandomFloat(-20, 20);
y = StyxWoW.Me.Location.Y + RandomNumber.GenerateRandomFloat(-20, 20);
} while(!Navigator.FindHeight(x, y, out z));
myNewWoWPoint = new WoWPoint(x, y, z);
} while(!Navigator.CanNavigateFully(StyxWoW.Me.Location, myNewWoWPoint) && myNewWoWPoint.Distance(StyxWoW.Me.Location) < 5);
DaVinci.CustomDiagnosticLog("Unstuck: Moving to " + myNewWoWPoint);
Navigator.MoveTo(myNewWoWPoint);
}
示例4: Pulse
//.........这里部分代码省略.........
Log("Looking for Hearthstone!.");
foreach (WoWItem _item in ObjectManager.GetObjectsOfType<WoWItem>().Where(o => o.BagSlot != 1 && o.Entry == 6948))
{
HasHeartStone = true;
Log("Has a Stone.");
if (_item.Cooldown < 1)
{
Log("Not on cooldown!");
DidUseHearth = true;
stone = _item;
Thread.Sleep(1000);
_item.Use();
HearthTimer.Start();
Thread.Sleep(2000);
while (Me.IsCasting) { Log("Sleep while Casting."); Thread.Sleep(100); }
Thread.Sleep(500);
if (HearthTimer.Elapsed.Seconds >= 9) { HearthTimer.Reset(); NeedHearth = false; Log("Hearthstone worked!"); }
else { HearthTimer.Reset(); NeedHearth = true; Log("Something Interrupted Hearthstone!"); return; }
}
}
if (!HasHeartStone) { Log("You don't have a HearthStone idiot. GO GET ONE! ExitNow!"); EXITNOW = true; return; }
return;
}
#endregion
#region AfterHearth
if (AfterHearth && !NeedHearth)
{
WoWPoint Outside = new WoWPoint(0, 0, 0);
Log("Sleepy for 5 seconds. At Home City.");
Thread.Sleep(5000);
ObjectManager.Update();
foreach (WoWUnit iKeeper in ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => (o.Entry == 6929 || o.Entry == 46642 || o.Entry == 44235 || o.Entry == 6740) && o.Location.Distance(Me.Location) < 30))
{
if (iKeeper.Entry == 6929)
{ Outside = new WoWPoint(1558.945, -4385.643, 16.88019); Log("Hearth set to Valley of Strength."); }
if (iKeeper.Entry == 46642)
{ Outside = new WoWPoint(1935.14, -4696.542, 35.96473); Log("Hearth set to Valley of Honor."); }
if (iKeeper.Entry == 44235)
{ Outside = new WoWPoint(-8380.801, 618.5749, 95.62397); Log("Hearth set to Dwarven district."); }
if (iKeeper.Entry == 6740)
{ Outside = new WoWPoint(-8853.698, 656.3289, 96.68601); Log("Hearth set to Trade district."); }
break;
}
Log("Moving Outside to prevent flying stucks.");
while (Outside.Distance(Me.Location) >= 3) { Navigator.MoveTo(Outside); }
AfterHearth = false;
return;
}
#endregion
if (!NeedHearth && !AfterHearth && NeedToRepairMailSell)
{ RepairSellMail(_Manager.Repair, _Manager.Sell, _Manager.Mail); return; }
#region IsNewZone
if (!SitAtHearth && !NeedHearth && !AfterHearth && !NeedToRepairMailSell && IsNewZone)
{
WoWPoint PortalsHorde = new WoWPoint(2055.473, -4378.082, 98.84528);
WoWPoint PortalsAlly = new WoWPoint(-8209.668, 428.5376, 118.0617);
if (Me.IsHorde)
{
//if (RepairAtHearth) { } //Embedded if sell at hearth
//if (MailAtHearth) { }
示例5: ArcaneBurn
/*
public bool ArcaneBurn()
{
if (!SpellManager.Spells["Evocation"].Cooldown && !SpellManager.Spells["Arcane Power"].Cooldown && !SpellManager.Spells["Mirror Image"] && !SpellManager.Item["Mana Gem"].Cooldown)//However you would do that check for mana gem//
{
return true;
}
}
*/
//only works with mobs, not players, need a new one for pvp.
public static bool WillChain(int Hits, WoWPoint TargetLocal)
{
List<WoWUnit> hitList = new List<WoWUnit>();
List<WoWUnit> enemyList = ObjectManager.GetObjectsOfType<WoWUnit>(false).FindAll(unit =>
unit.Attackable &&
!unit.IsFriendly &&
!unit.Combat &&
unit != Me &&
unit != Me.CurrentTarget);
foreach (WoWUnit Plr in enemyList)
{
if (TargetLocal.Distance(Plr.Location) < 8)
{
hitList.Add(Plr);
}
}
if (hitList.Count > Hits)
{
Log("Found Targets {0} near CurrentTarget", hitList.Count.ToString());
hitList.Clear();
return true;
}
else
{
hitList.Clear();
return false;
}
}
示例6: IsKitingPossible
public static bool IsKitingPossible(int minScan = -1)
{
if (MovementManager.IsMovementDisabled)
return false;
if (!SingularRoutine.IsAllowed(CapabilityFlags.Kiting))
return false;
// note: PullDistance MUST be longer than our out of melee distance (DISTANCE_WE_NEED_TO_START_BACK_PEDDLING)
// otherwise it will run back and forth
if (IsKitingActive() || !Me.IsAlive || Spell.IsCasting())
return false;
if (Me.Stunned || Me.IsStunned())
{
Logger.WriteDebug("IsKitingPossible: suppressed while Stunned");
return false;
}
if (Me.Rooted || Me.IsRooted())
{
Logger.WriteDebug("IsKitingPossible: suppressed while Rooted");
return false;
}
if (Me.IsFalling)
{
Logger.WriteDebug("IsKitingPossible: suppressed while Falling");
return false;
}
WoWUnit mob = SafeArea.NearestEnemyMobAttackingMe;
//mob = Me.CurrentTarget; // FOR TESTING ONLY
if (mob == null)
{
Logger.WriteDebug("IsKitingPossible: error - cannot find a Mob Near us to Kite away from");
return false;
}
// check if 5yds beyond melee
if (mob.SpellDistance() > 10f)
{
Logger.WriteDebug("IsKitingPossible: {0} @ {1:F1} yds is already > 10 yds away", mob.SafeName(), mob.SpellDistance());
return false;
}
SafeArea sa = new SafeArea();
if (Battlegrounds.IsInsideBattleground)
{
sa.MinSafeDistance = 12;
sa.MinScanDistance = minScan == -1 ? 15 : minScan;
sa.IncrementScanDistance = 10;
sa.MaxScanDistance = sa.MinScanDistance + 2 * sa.IncrementScanDistance;
sa.RaysToCheck = 18;
sa.MobToRunFrom = mob;
sa.LineOfSightMob = Me.CurrentTarget;
sa.CheckLineOfSightToSafeLocation = false;
sa.CheckSpellLineOfSightToMob = false;
sa.DirectPathOnly = true; // faster to check direct path than navigable route
}
else
{
sa.MinSafeDistance = 20;
sa.MinScanDistance = minScan == -1 ? 10 : minScan;
sa.IncrementScanDistance = 5;
sa.MaxScanDistance = sa.MinScanDistance + (2 * sa.IncrementScanDistance);
sa.RaysToCheck = 36;
sa.MobToRunFrom = mob;
sa.LineOfSightMob = Me.CurrentTarget;
sa.CheckLineOfSightToSafeLocation = false;
sa.CheckSpellLineOfSightToMob = false;
sa.DirectPathOnly = true; // faster to check direct path than navigable route
}
locSafeSpot = sa.FindLocation();
if (locSafeSpot == WoWPoint.Empty)
{
return false;
}
return BeginKiting(String.Format("^Kiting(begin): moving {0:F1} yds away from {1}", locSafeSpot.Distance(StyxWoW.Me.Location), mob.SafeName()));
}
示例7: FindLocation
public WoWPoint FindLocation(WoWPoint ptOrigin)
{
DateTime startFind = DateTime.Now;
int countPointsChecked = 0;
int countFailToPointNav = 0;
int countFailRange = 0;
int countFailSafe = 0;
int countFailToPointLoS = 0;
int countFailToMobLoS = 0;
double furthestNearMobDistSqr = 0f;
WoWPoint ptFurthest = WoWPoint.Empty;
bool reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget;
WoWPoint ptAdjOrigin = ptOrigin;
ptAdjOrigin.Z += 1f;
WoWPoint ptDestination = new WoWPoint();
List<WoWPoint> mobLocations = new List<WoWPoint>();
float arcIncrement = ((float)Math.PI * 2) / RaysToCheck;
mobLocations = AllEnemyMobLocationsToCheck;
double minSafeDistSqr = MinSafeDistance * MinSafeDistance;
float baseDestinationFacing = MobToRunFrom == null ?
Me.RenderFacing + (float)Math.PI
: Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
// Logger.WriteDebug( Color.Cyan, "SafeArea: search near {0:F0}d @ {1:F1} yds for mob free area", RadiansToDegrees(baseDestinationFacing), MinSafeDistance);
for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
{
// rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
// .. so we favor a position furthest away from mob
float checkFacing = baseDestinationFacing;
if ((arcIndex & 1) == 0)
checkFacing += arcIncrement * (arcIndex >> 1);
else
checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);
for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
{
countPointsChecked++;
ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);
if (!Navigator.CanNavigateFully(Me.Location, ptDestination))
{
// Logger.WriteDebug( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
countFailToPointNav++;
continue;
}
WoWPoint ptNearest = NearestMobLoc(ptDestination, mobLocations);
if (ptNearest == WoWPoint.Empty)
{
if (furthestNearMobDistSqr < minSafeDistSqr)
{
furthestNearMobDistSqr = minSafeDistSqr;
ptFurthest = ptDestination; // set best available if others fail
}
}
else
{
double mobDistSqr = ptDestination.Distance2DSqr(ptNearest);
if (furthestNearMobDistSqr < mobDistSqr)
{
furthestNearMobDistSqr = mobDistSqr;
ptFurthest = ptDestination; // set best available if others fail
}
if (mobDistSqr <= minSafeDistSqr)
{
countFailSafe++;
continue;
}
}
if (reallyCheckRangeToLineOfSightMob && RangeToLineOfSightMob < ptDestination.Distance(LineOfSightMob.Location) - LineOfSightMob.MeleeDistance())
{
countFailRange++;
continue;
}
if (CheckLineOfSightToSafeLocation)
{
WoWPoint ptAdjDest = ptDestination;
ptAdjDest.Z += 1f;
if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptAdjOrigin, ptAdjDest))
{
// Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
countFailToPointLoS++;
continue;
}
}
if (CheckSpellLineOfSightToMob && LineOfSightMob != null)
{
if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(ptDestination, LineOfSightMob.Location))
{
if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptDestination, LineOfSightMob.Location))
{
// Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
countFailToMobLoS++;
//.........这里部分代码省略.........
示例8: MoveToLocation
public static void MoveToLocation(WoWPoint loc)
{
while (loc.Distance(Me.Location) > 3)
{
Flightor.MountHelper.MountUp();
Navigator.MoveTo(loc);
}
}
示例9: nodeIsBlacklisted
public static bool nodeIsBlacklisted(WoWPoint wp)
{
List<Stopwatch> sw = blackList.Keys.ToList();
for (int i = blackList.Count - 1; i >= 0; i--)
{
if (sw[i].Elapsed.TotalMinutes >= blackListTime)
{
blackList.Remove(sw[i]);
}
}
foreach (WoWPoint wowp in blackList.Values)
{
if (wp.Distance(wowp) < 50)
{
return true;
}
}
return false;
}
示例10: TotemManagerUpdate
private bool TotemManagerUpdate()
{
int countTotems = 0;
_ptTotems = new WoWPoint();
_totem = new WoWUnit[5];
#if USE_OLD_SEARCH
List<WoWUnit> totemList = (from o in ObjectManager.ObjectList
where o is WoWUnit
let unit = o.ToUnit()
where unit.CreatedByUnitGuid == _me.Guid
&& unit.CreatureType == WoWCreatureType.Totem
select unit
).ToList();
foreach (WoWUnit totem in totemList)
{
int indexTotem = 0;
try
{
countTotems++;
indexTotem = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
_totem[indexTotem] = totem;
if ( totem.Distance < _ptTotems.Distance(_me.Location) )
_ptTotems = totem.Location;
}
catch
{
Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER: Unknown totem: totem spell id={0}, totem name='{1}', index totem={2}", totem.CreatedBySpellId, totem.Name, indexTotem);
}
}
#else
foreach (WoWTotemInfo ti in _me.Totems)
{
if (ti.WoWTotem != WoWTotem.None)
{
countTotems++;
try
{
WoWUnit totem = ObjectManager.GetObjectByGuid<WoWUnit>(ti.Guid);
int indexTotem = _dictTotemSlot[(TotemId)totem.CreatedBySpellId];
_totem[indexTotem] = totem;
if (totem.Distance < _ptTotems.Distance(_me.Location))
_ptTotems = totem.Location;
}
catch
{
Shaman.Wlog("NOTIFY SHAMWOW DEVELOPER: Unknown totem: totem spell id={0}, totem name='{1}'", ti.Spell.Id, ti.Name );
}
}
}
#endif
#if SHOW_TOTEM_COUNT
if ( countTotems > 0 )
Shaman.Dlog("TotemManagerUpdate: found {0} totems with closest {1:F1} yds away at {2}", countTotems, _ptTotems.Distance(_me.Location), _ptTotems.ToString());
#endif
return countTotems > 0;
}
示例11: GetClosestObjectSalesmanHb
public static WoWGameObject GetClosestObjectSalesmanHb(WoWPoint from, WoWGameObject[] objectsToArray)
{
PathGenerationStopwatch.Reset();
PathGenerationStopwatch.Start();
GarrisonButler.Diagnostic("Starting salesman algorithm.");
//Generating data
var objectsTo = objectsToArray.OrderBy(o => from.Distance(o.Location)).Take(5).ToArray();
var objectsCount = objectsTo.Count();
var vertics = new int[objectsCount + 1];
var matrix = new double[objectsCount + 1, objectsCount + 1];
// Adding starting point
vertics[0] = 0;
matrix[0, 0] = 0;
// Adding distance from starting point to all objects
for (int index = 0; index < objectsTo.Length; index++)
{
var gameObject = objectsTo[index];
var distance = Navigator.PathDistance(@from, gameObject.Location) ?? float.MaxValue;
matrix[0, index + 1] = (float)distance;
matrix[index + 1, 0] = (float)distance;
}
// Adding distances from every points to all others
for (int index1 = 0; index1 < objectsTo.Length; index1++)
{
vertics[index1 + 1] = index1 + 1;
for (int index2 = index1; index2 < objectsTo.Length; index2++)
{
if (index1 == index2)
matrix[index1 + 1, index2 + 1] = 0.0;
else
{
var distance = Navigator.PathDistance(@from, objectsTo[index2].Location) ?? float.MaxValue;
matrix[index1 + 1, index2 + 1] = distance;
matrix[index2 + 1, index1 + 1] = distance;
}
}
GarrisonButler.Diagnostic("[Salesman] Processed node in {0}ms", PathGenerationStopwatch.ElapsedMilliseconds);
}
double cost;
var salesman = new Salesman(vertics, matrix);
var route = salesman.Solve(out cost).ToArray();
PathGenerationStopwatch.Stop();
GarrisonButler.Diagnostic("[Salesman] Tour found in {0}ms, cost={1}, route:", PathGenerationStopwatch.ElapsedMilliseconds, cost);
ObjectDumper.WriteToHb(route, 3);
return objectsTo[route[1] - 1];
}
示例12: getSaveLocation
public static WoWPoint getSaveLocation(WoWPoint Location, int minDist, int maxDist, int traceStep)
{
Logging.WriteNavigator("{0} - Navigation: Looking for save Location around {1}.", TimeNow, Location);
float _PIx2 = 3.14159f * 2f;
for (int i = 0, x = minDist; i < traceStep && x < maxDist; i++)
{
WoWPoint p = Location.RayCast((i * _PIx2) / traceStep, x);
p.Z = getGroundZ(p);
WoWPoint pLoS = p;
pLoS.Z = p.Z + 0.5f;
if (p.Z != float.MinValue && StyxWoW.Me.Location.Distance(p) > 1)
{
if (getHighestSurroundingSlope(p) < 1.2f && GameWorld.IsInLineOfSight(pLoS, Location) /*&& Navigator.CanNavigateFully(StyxWoW.Me.Location, Location)*/)
{
Logging.WriteNavigator("{0} - Navigation: Moving to {1}. Distance: {2}", TimeNow, p, Location.Distance(p));
return p;
}
}
if (i == (traceStep - 1))
{
i = 0;
x++;
}
}
Logging.Write(System.Drawing.Color.Red, "{0} - No valid points returned by RayCast...", TimeNow);
return WoWPoint.Empty;
}
示例13: CreatePathSegment
List<WoWPoint> CreatePathSegment(WoWPoint from, WoWPoint to, Height ht)
{
List<WoWPoint> segment = new List<WoWPoint>();
WoWPoint point = from;
float step = 50;
float noMeshStep = 5;
for (float i = from.Distance(to) - step; i > 0; )
{
point = WoWMathHelper.CalculatePointFrom(from, to, i);
try
{
float z = ht == Height.High ? Navigator.FindHeights(point.X, point.Y).Max() :
Navigator.FindHeights(point.X, point.Y).Min();
i -= step;
/* TODO - REENABLE THISif (Gui.smoothCheck.Checked && z > point.Z)
{
point.Z = z;
}
* */
segment.Add(point);
}
catch { i -= noMeshStep; }
}
segment.Add(to);
return segment;
}
示例14: MoveToLocation
public static void MoveToLocation(WoWPoint loc)
{
while (loc.Distance(StyxWoW.Me.Location) > 3) {
if (!Flightor.MountHelper.Mounted) {
Flightor.MountHelper.MountUp();
}
if (!StyxWoW.Me.IsMoving) {
Flightor.MoveTo(loc);
}
}
}
示例15: Pulse
public override void Pulse()
{
#region pulsechecks
if (!TreeRoot.IsRunning)
return;
if (Me.Combat && !Me.GotTarget)
{
GetClosestLiveUnitByID(24978).Target();
}
if (Me.Combat || Me.Dead || Me.IsGhost || Me.IsResting)
return;
#endregion
QuestlistUpdate();
//Logging.WriteDebug(TreeRoot.GoalText);
if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Poratl x 1")
TreeRoot.GoalText = "DHX Goal: Take Poratl Reading";
if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Sunwell x 1")
TreeRoot.GoalText = "DHX Goal: Take BloodCrystal Reading";
if (TreeRoot.GoalText == "Goal: Kill Sunwell - Quest Bunny - Shrine x 1")
TreeRoot.GoalText = "DHX Goal: Take Shrine Reading";
if (TreeRoot.GoalText == "Goal: Kill mob with ID 25086 10 times")
TreeRoot.GoalText = "DHX Goal: Free 10 Greengill Slaves";
#region looting fix
List<WoWUnit> LootMobList = ObjectManager.GetObjectsOfType<WoWUnit>();
if (!StyxWoW.Me.Combat)
{
foreach (WoWUnit unit in LootMobList)
{
if (!unit.IsAlive && unit.CanLoot)
{
while (StyxWoW.Me.Location.Distance(unit.Location) > 4 || unit.CanLoot)
{
try
{
WoWMovement.ClickToMove(unit.Location);
}
catch { }
if (StyxWoW.Me.Location.Distance(unit.Location) <= 4)
{
try
{
if (unit.CanLoot)
{
unit.Interact();
Styx.Logic.Inventory.Frames.LootFrame.LootFrame.Instance.LootAll();
LootMobList.Remove(unit);
}
else if (unit.CanLoot)
{
while (unit.CanLoot)
{
unit.Interact();
Styx.Logic.Inventory.Frames.LootFrame.LootFrame.Instance.LootAll();
}
LootMobList.Remove(unit);
}
}
catch { }
}
}
}
}
}
if (!StyxWoW.Me.GotTarget && !StyxWoW.Me.Combat && Styx.Logic.LootTargeting.Instance.LootingList.Count == 0)
{
LootMobList.Clear();
}
#endregion
#region bloodberry bush loot reliability
WoWObject bloddberrybush = GetClosestObjectByID(187333);
if (bloddberrybush != null)
{
if (bloddberrybush.Distance < 5 && !Me.Combat)
{
bloddberrybush.Interact();
}
}
#endregion
#region emissary of hate
if(InvChkByID(34414))
{
if (Me.CanLoot || Me.Looting)
return;
WoWUnit emissary = GetUnitByID(25003);
if (emissary != null)
{
if (emissary.Dead && emissary.Distance < 10)
{
useItemByID(34414);
}
}
}
#endregion
#region dont stop now
ObjectManager.Update();
while (KeyChkByID(34477) && InvTotalByID(34479) < 3 && IsQuestCompleted(11547))
{
Logging.WriteDebug("found key");
WoWObject orechest = GetClosestObjectByID(187264);
if (orechest != null)
//.........这里部分代码省略.........