本文整理汇总了C#中System.Result.Lock方法的典型用法代码示例。如果您正苦于以下问题:C# Result.Lock方法的具体用法?C# Result.Lock怎么用?C# Result.Lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Result
的用法示例。
在下文中一共展示了Result.Lock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImmobilePrediction
/// <summary>
/// Gets Prediction result while unit is immobile
/// </summary>
/// <param name="target">Target for spell</param>
/// <param name="width">Spell width</param>
/// <param name="delay">Spell delay</param>
/// <param name="missileSpeed">Spell missile speed</param>
/// <param name="range">Spell range</param>
/// <param name="collisionable">Spell collisionable</param>
/// <param name="type">Spell skillshot type</param>
/// <param name="from">Spell casted position</param>
/// <returns></returns>
internal static Result GetImmobilePrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, SkillshotType type, Vector2 from, Vector2 rangeCheckFrom)
{
Result result = new Result();
result.Input = new Input(target, delay, missileSpeed, width, range, collisionable, type, from.To3D2(), rangeCheckFrom.To3D2());
result.Unit = target;
result.CastPosition = target.ServerPosition.To2D();
result.UnitPosition = result.CastPosition;
//calculate spell arrival time
float t = delay + Game.Ping / 2000f;
if (missileSpeed != 0)
t += from.Distance(target.ServerPosition) / missileSpeed;
if (type == SkillshotType.SkillshotCircle)
t += width / target.MoveSpeed / 2f;
if (t >= Utility.LeftImmobileTime(target))
{
result.HitChance = HitChance.Immobile;
result.Lock();
return result;
}
if (target is Obj_AI_Hero)
result.HitChance = GetHitChance(t - Utility.LeftImmobileTime(target), ((Obj_AI_Hero)target).AvgMovChangeTime(), 0, 0, 0);
else
result.HitChance = HitChance.High;
result.Lock();
return result;
}
示例2: GetPrediction
/// <summary>
/// Gets Prediction result
/// </summary>
/// <param name="target">Target for spell</param>
/// <param name="width">Spell width</param>
/// <param name="delay">Spell delay</param>
/// <param name="missileSpeed">Spell missile speed</param>
/// <param name="range">Spell range</param>
/// <param name="collisionable">Spell collisionable</param>
/// <param name="type">Spell skillshot type</param>
/// <param name="path">Waypoints of target</param>
/// <param name="avgt">Average reaction time (in ms)</param>
/// <param name="movt">Passed time from last movement change (in ms)</param>
/// <param name="avgp">Average Path Lenght</param>
/// <param name="from">Spell casted position</param>
/// <param name="rangeCheckFrom"></param>
/// <returns>Prediction result as <see cref="Prediction.Result"/></returns>
internal static Result GetPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, SkillshotType type, List<Vector2> path, float avgt, float movt, float avgp, float anglediff, Vector2 from, Vector2 rangeCheckFrom)
{
Prediction.AssertInitializationMode();
Result result = new Result();
result.Input = new Input(target, delay, missileSpeed, width, range, collisionable, type, from.To3D2(), rangeCheckFrom.To3D2());
result.Unit = target;
try
{
if (type == SkillshotType.SkillshotCircle)
range += width;
//to do: hook logic ? by storing average movement direction etc
if (path.Count <= 1 && movt > 100 && (Environment.TickCount - PathTracker.EnemyInfo[target.NetworkId].LastAATick > 300 || !ConfigMenu.CheckAAWindUp)) //if target is not moving, easy to hit (and not aaing)
{
result.HitChance = HitChance.VeryHigh;
result.CastPosition = target.ServerPosition.To2D();
result.UnitPosition = result.CastPosition;
result.Lock();
return result;
}
if (target is Obj_AI_Hero)
{
if (((Obj_AI_Hero)target).IsChannelingImportantSpell())
{
result.HitChance = HitChance.VeryHigh;
result.CastPosition = target.ServerPosition.To2D();
result.UnitPosition = result.CastPosition;
result.Lock();
return result;
}
if (Environment.TickCount - PathTracker.EnemyInfo[target.NetworkId].LastAATick < 300 && ConfigMenu.CheckAAWindUp)
{
if (target.AttackCastDelay * 1000 + PathTracker.EnemyInfo[target.NetworkId].AvgOrbwalkTime + avgt - width / 2f / target.MoveSpeed >= GetArrivalTime(target.ServerPosition.To2D().Distance(from), delay, missileSpeed))
{
result.HitChance = HitChance.High;
result.CastPosition = target.ServerPosition.To2D();
result.UnitPosition = result.CastPosition;
result.Lock();
return result;
}
}
//to do: find a fuking logic
if (avgp < 400 && movt < 100 && path.PathLength() <= avgp)
{
result.HitChance = HitChance.High;
result.CastPosition = path.Last();
result.UnitPosition = result.CastPosition;
result.Lock();
return result;
}
}
if (target.IsDashing()) //if unit is dashing
return GetDashingPrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom);
if (Utility.IsImmobileTarget(target)) //if unit is immobile
return GetImmobilePrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom);
result = WaypointAnlysis(target, width, delay, missileSpeed, range, collisionable, type, path, avgt, movt, avgp, anglediff, from);
float d = result.CastPosition.Distance(target.ServerPosition.To2D());
if (d >= (avgt - movt) * target.MoveSpeed && d >= avgp)
result.HitChance = HitChance.Medium;
result.Lock();
return result;
}
finally
{
//check if movement changed while prediction calculations
if (!target.GetWaypoints().SequenceEqual(path))
result.HitChance = HitChance.Medium;
}
//.........这里部分代码省略.........
示例3: GetDashingPrediction
/// <summary>
/// Gets Prediction result while unit is dashing
/// </summary>
/// <param name="target">Target for spell</param>
/// <param name="width">Spell width</param>
/// <param name="delay">Spell delay</param>
/// <param name="missileSpeed">Spell missile speed</param>
/// <param name="range">Spell range</param>
/// <param name="collisionable">Spell collisionable</param>
/// <param name="type">Spell skillshot type</param>
/// <param name="from">Spell casted position</param>
/// <returns></returns>
internal static Result GetDashingPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, SkillshotType type, Vector2 from, Vector2 rangeCheckFrom)
{
Result result = new Result();
result.Input = new Input(target, delay, missileSpeed, width, range, collisionable, type, from.To3D2(), rangeCheckFrom.To3D2());
result.Unit = target;
if (target.IsDashing())
{
var dashInfo = target.GetDashInfo();
if (dashInfo.IsBlink)
{
result.HitChance = HitChance.Impossible;
result.CastPosition = dashInfo.EndPos;
return result;
}
result.CastPosition = GetFastUnitPosition(target, dashInfo.Path, delay, missileSpeed, from, dashInfo.Speed);
result.HitChance = HitChance.Dashing;
result.Lock(false);
}
else
{
result = GetPrediction(target, width, delay, missileSpeed, range, collisionable, type, target.GetWaypoints(), 0, 0, 0, 0, from, rangeCheckFrom);
result.Lock(false);
}
return result;
}