本文整理汇总了C#中WoWUnit.DistanceCalc方法的典型用法代码示例。如果您正苦于以下问题:C# WoWUnit.DistanceCalc方法的具体用法?C# WoWUnit.DistanceCalc怎么用?C# WoWUnit.DistanceCalc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WoWUnit
的用法示例。
在下文中一共展示了WoWUnit.DistanceCalc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: On_PetCast
public static bool On_PetCast(string spellname, WoWUnit target, bool castnow)
{
string fnname = "FTWCore.On_PetCast";
MyTimer.Start(fnname);
LocalPlayer Me = StyxWoW.Me;
WoWPetSpell spell = null;
// Don't even try to cast if I don't have a pet.
if (!Me.GotAlivePet)
{
MyTimer.Stop(fnname);
return false;
}
foreach (WoWPetSpell sp in StyxWoW.Me.PetSpells)
{
if (sp.Action.ToString() == spellname)
{
Lua.DoString("CastPetAction({0})", sp.ActionBarIndex + 1);
FTWLogger.log("[Pet] Action = {0}", sp.Action.ToString());
break;
}
else if (sp.Spell != null && sp.Spell.Name == spellname)
{
spell = sp;
break;
}
}
if (spell == null)
{
FTWLogger.debug(Color.Gray, "[Pet] Unknown spell {0}", spellname);
MyTimer.Stop(fnname);
return false;
}
if (FTWCoreStatus.OnPetCooldown(spellname))
{
MyTimer.Stop(fnname);
return false;
}
if (!castnow && (Me.Pet.IsCasting || Me.Pet.IsChanneling))
{
MyTimer.Stop(fnname);
return false;
}
if (spell.Spell.MinRange > 0 && target.DistanceCalc() < spell.Spell.MinRange)
{
FTWLogger.debug(Color.Yellow, "[Pet] Too close to {0} to cast {1}.", target.SafeName(), spell.Spell.Name);
MyTimer.Stop(fnname);
return false;
}
if (spell.Spell.MaxRange > 0 && target.DistanceCalc() > spell.Spell.MaxRange)
{
FTWLogger.debug(Color.Yellow, "[Pet] Too far away to {0} to cast {1}.", target.SafeName(), spell.Spell.Name);
MyTimer.Stop(fnname);
return false;
}
string strTarget;
if (target.Guid == StyxWoW.Me.Guid)
strTarget = "player";
else if (target.Guid == StyxWoW.Me.Pet.Guid)
strTarget = "pet";
else if (target.Guid == StyxWoW.Me.CurrentTargetGuid)
strTarget = "target";
else
strTarget = null;
if (strTarget == null)
{
Lua.DoString("CastPetAction({0})", spell.ActionBarIndex + 1);
FTWLogger.log(" [Pet] Cast {0}", spell.Spell.Name);
}
else
{
Lua.DoString("CastPetAction({0}, {1})", spell.ActionBarIndex + 1, strTarget);
FTWLogger.log(" [Pet] Cast {0} on {1} health {2:0.0} dist {3:0.0}", spell.Spell.Name, strTarget, target.HealthPercent, target.DistanceCalc());
}
if (spell.Spell.IsAreaSpell())
{
// Area spell
WoWPoint loc;
if (spell.Spell.IsSelfOnlySpell)
loc = StyxWoW.Me.Location;
else
loc = target.Location;
DateTime stoptime = DateTime.Now.AddMilliseconds(500);
while (DateTime.Now < stoptime)
{
if (StyxWoW.Me.CurrentPendingCursorSpell != null)
break;
Thread.Sleep(10);
}
SpellManager.ClickRemoteLocation(loc);
//.........这里部分代码省略.........
示例2: On_Cast
//.........这里部分代码省略.........
}
}
if (false)
{
// Check power requirements
List<string> values = Lua.GetReturnValues(String.Format("return GetSpellInfo({0})", spell.Id), "SpellInfo.lua");
//string[] vars = {"name", "rank", "icon", "cost", "isFunnel", "powerType", "castTime", "minRange", "maxRange"};
int powerType = Int32.Parse(values[5]);
int powerCost = Int32.Parse(values[3]);
string[] powertypes = { "mana", "rage", "focus", "energy",
"happiness", "runes", "runic power", "soul shards",
"eclipse", "holy power", "alternate power", "dark force",
"chi", "shadow orbs", "burning embers", "demonic fury"
};
if (StyxWoW.Me.UnitPower(powerType) < powerCost)
{
FTWLogger.log(Color.Orange, "NOT ENOUGH {0} - Requires: {1}, but I have: {2}", powertypes[powerType], powerCost, StyxWoW.Me.UnitPower(powerType));
MyTimer.Stop(fnname);
return false;
}
}
if (!spell.IsSelfOnlySpell)
{
if (target == null)
{
FTWLogger.log(Color.Orange, "Can't cast {0} on null target!", spell.Name);
if (debugspell)
FTWLogger.log(ds, "Null target");
MyTimer.Stop(fnname);
return false;
}
double dist = target.Distance; // target.DistanceCalc();
if ((spell.MinRange > 0 || spell.MaxRange > 0) && !(dist >= spell.MinRange && dist <= spell.MaxRange))
{
FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} minrange {5} maxrange {6}", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc(), spell.MinRange, spell.MaxRange);
if (debugspell)
FTWLogger.log(ds, "Out of range");
MyTimer.Stop(fnname);
return false;
}
if (!target.InLineOfSight)
{
FTWLogger.log(Color.Orange, "Can't cast spell {0} {1} on {2} health {3:0.0} dist {4:0.0} (not in line of sight)", spellname, spell.Id, target.SafeName(), target.HealthPercent, target.DistanceCalc());
if (debugspell)
FTWLogger.log(ds, "Not in line of sight. Attempts = {0}.", FTWProps.not_in_los_attempts);
MyTimer.Stop(fnname);
FTWProps.not_in_los_attempts += 1;
Navigator.MoveTo(target.Location);
Thread.Sleep(2000);
return false;
}
if (spellname == "Death Pact" && Me.GotAlivePet)
{
Me.Pet.Target();
for (int l = 0; l < 2; l++)
Thread.Sleep(10);
}
if (FTWProps.CastOver.Contains(FTWProps.lastspellcastname))
retval = true;
else if (spell.IsSelfOnlySpell)
retval = SpellManager.CanCast(spell, true);