本文整理汇总了C#中Obj_AI_Base.Distance2方法的典型用法代码示例。如果您正苦于以下问题:C# Obj_AI_Base.Distance2方法的具体用法?C# Obj_AI_Base.Distance2怎么用?C# Obj_AI_Base.Distance2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obj_AI_Base
的用法示例。
在下文中一共展示了Obj_AI_Base.Distance2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHealthPrediction
/// <summary>
/// Returns the unit health after a set time milliseconds.
/// </summary>
public static float GetHealthPrediction(Obj_AI_Base unit, int time, int delay = 70)
{
var predictedDamage = 0f;
foreach (var attack in ActiveAttacks.Values)
{
var attackDamage = 0f;
if (!attack.Processed && attack.Source.IsValidTarget(float.MaxValue, false) &&
attack.Target.IsValidTarget(float.MaxValue, false) && attack.Target.NetworkId == unit.NetworkId)
{
var landTime = attack.StartTick + attack.Delay +
1000 * Math.Max(0, unit.Distance2(attack.Source) - attack.Source.BoundingRadius) / attack.ProjectileSpeed + delay;
if (/*Utils.GameTimeTickCount < landTime - delay &&*/ landTime < Utils.GameTimeTickCount + time)
{
attackDamage = attack.Damage;
}
}
predictedDamage += attackDamage;
}
return unit.Health - predictedDamage;
}
示例2: LaneClearHealthPrediction
/// <summary>
/// Returns the unit health after time milliseconds assuming that the past auto-attacks are periodic.
/// </summary>
public static float LaneClearHealthPrediction(Obj_AI_Base unit, int time, int delay = 70)
{
var predictedDamage = 0f;
foreach (var attack in ActiveAttacks.Values)
{
var n = 0;
if (Utils.GameTimeTickCount - 100 <= attack.StartTick + attack.AnimationTime &&
attack.Target.IsValidTarget(float.MaxValue, false) &&
attack.Source.IsValidTarget(float.MaxValue, false) && attack.Target.NetworkId == unit.NetworkId)
{
var fromT = attack.StartTick;
var toT = Utils.GameTimeTickCount + time;
while (fromT < toT)
{
if (fromT >= Utils.GameTimeTickCount &&
(fromT + attack.Delay + Math.Max(0, unit.Distance2(attack.Source) - attack.Source.BoundingRadius) / attack.ProjectileSpeed < toT))
{
n++;
}
fromT += (int)attack.AnimationTime;
}
}
predictedDamage += n * attack.Damage;
}
return unit.Health - predictedDamage;
}