本文整理汇总了C#中Unit.GetTurnTime方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.GetTurnTime方法的具体用法?C# Unit.GetTurnTime怎么用?C# Unit.GetTurnTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.GetTurnTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CastSpell
private static void CastSpell(Unit hero, ExecuteOrderEventArgs args)
{
var spell = args.Ability;
if (hero == null || spell == null || spell.ManaCost <= 25 || IgnoredSpells.Any(spell.Name.Contains))
return;
var powerTreads = hero.FindItem("item_power_treads");
if (powerTreads == null)
return;
args.Process = false;
var sleep = spell.FindCastPoint() * 1000 + 555;
switch (args.Order) {
case Order.AbilityTarget: {
var target = (Unit) args.Target;
if (target != null && target.IsAlive) {
var castRange = spell.GetCastRange() + 300;
if (hero.Distance2D(target) <= castRange) {
ChangePt(powerTreads, Attribute.Intelligence);
sleep += hero.GetTurnTime(target) * 1000;
}
spell.UseAbility(target);
}
break;
}
case Order.AbilityLocation: {
var castRange = spell.GetCastRange() + 300;
if (hero.Distance2D(Game.MousePosition) <= castRange) {
ChangePt(powerTreads, Attribute.Intelligence);
sleep += hero.GetTurnTime(Game.MousePosition) * 1000;
}
spell.UseAbility(Game.MousePosition);
break;
}
case Order.Ability: {
ChangePt(powerTreads, Attribute.Intelligence);
spell.UseAbility();
break;
}
case Order.ToggleAbility: {
ChangePt(powerTreads, Attribute.Intelligence);
spell.ToggleAbility();
break;
}
}
Utils.Sleep(sleep, "delay");
}
示例2: GetCastDelay
/// <summary>
/// Returns delay before ability is casted
/// </summary>
/// <param name="ability">
/// The ability.
/// </param>
/// <param name="source">
/// The source.
/// </param>
/// <param name="target">
/// The target.
/// </param>
/// <param name="abilityLevel">
/// The ability Level.
/// </param>
/// <param name="usePing">
/// The use Ping.
/// </param>
/// <param name="useCastPoint">
/// The use Cast Point.
/// </param>
/// <param name="abilityName">
/// The ability Name.
/// </param>
/// <param name="useChannel">
/// The use Channel.
/// </param>
/// <returns>
/// The <see cref="double" />.
/// </returns>
public static double GetCastDelay(
this Ability ability,
Unit source,
Unit target,
uint abilityLevel,
bool usePing = false,
bool useCastPoint = true,
string abilityName = null,
bool useChannel = false)
{
if (ability == null || !ability.IsValid)
{
return 0;
}
if (target == null || !target.IsValid || source == null || !source.IsValid)
{
return 0;
}
var level = abilityLevel != 0 ? abilityLevel : ability.Level;
var name = abilityName ?? ability.StoredName();
double delay;
if (useCastPoint)
{
if (!delayDictionary.TryGetValue(name + " " + level, out delay))
{
delay = Math.Max(ability.FindCastPoint(name), 0.07);
delayDictionary.Add(name + " " + level, delay);
}
if (name == "templar_assassin_meld")
{
delay += UnitDatabase.GetAttackPoint(source) + Game.Ping / 500 + 0.1 + source.GetTurnTime(target);
}
if (name == "item_diffusal_blade" || name == "item_diffusal_blade_2")
{
delay += 2;
}
}
else
{
if (ability is Item)
{
delay = 0;
}
else
{
delay = 0.05;
}
}
if (usePing)
{
delay += Game.Ping / 1000;
}
if (useChannel)
{
delay += ability.ChannelTime(level, name);
}
if (!ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
return Math.Max(delay + (!target.Equals(source) ? source.GetTurnTime(target) : 0), 0);
}
return Math.Max(delay, 0);
}
示例3: GetAvailableTrees
private IEnumerable<Tree> GetAvailableTrees(
Unit hero,
Vector3 target,
float range,
double time = 0,
float speed = 1)
{
return
allTrees.OrderBy(x => x.Distance2D(target))
.Where(
x =>
x.Distance2D(hero) <= range && NavMesh.GetCellFlags(x.Position).HasFlag(NavMeshCellFlags.Tree)
&& (time <= 0
|| !unavailableTrees.Any(
z =>
z.Item1.Distance2D(x) <= z.Item2
&& time + hero.GetTurnTime(x) + x.Distance2D(hero) / speed >= z.Item3)));
}