本文整理汇总了C#中Unit.Vector3FromPolarAngle方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.Vector3FromPolarAngle方法的具体用法?C# Unit.Vector3FromPolarAngle怎么用?C# Unit.Vector3FromPolarAngle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.Vector3FromPolarAngle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PredictedXYZ
/// <summary>
/// Returns predicted location of given unit after given delay in ms
/// </summary>
/// <param name="unit"></param>
/// <param name="delay"></param>
/// <returns></returns>
public static Vector3 PredictedXYZ(Unit unit, float delay)
{
Vector3 targetSpeed;
if ((!SpeedDictionary.TryGetValue(unit.Handle, out targetSpeed) || targetSpeed == new Vector3(0, 0, 0))
&& unit.NetworkActivity == NetworkActivity.Move)
{
var rotSpeed = 0d;
if (RotSpeedDictionary.ContainsKey(unit.Handle))
{
rotSpeed = RotSpeedDictionary[unit.Handle];
}
targetSpeed = unit.Vector3FromPolarAngle((float)rotSpeed) * (unit.MovementSpeed) / 1000;
}
//Console.WriteLine(targetSpeed + " " + unit.Name);
if (IsIdle(unit))
{
return unit.Position;
}
var v = unit.Position + targetSpeed * delay;
return new Vector3(v.X, v.Y, 0);
}
示例2: InFront
/// <summary>
/// Returns vector in facing direction of given unit with given distance
/// </summary>
/// <param name="unit"></param>
/// <param name="distance"></param>
/// <returns></returns>
public static Vector3 InFront(Unit unit, float distance)
{
var v = unit.Position + unit.Vector3FromPolarAngle() * distance;
return new Vector3(v.X, v.Y, 0);
}
示例3: PredictedXYZ
/// <summary>
/// Returns predicted location of given unit after given delay in ms
/// </summary>
/// <param name="unit">
/// The unit.
/// </param>
/// <param name="delay">
/// The delay.
/// </param>
/// <returns>
/// The <see cref="Vector3" />.
/// </returns>
public static Vector3 PredictedXYZ(Unit unit, float delay)
{
if (IsIdle(unit))
{
return unit.Position;
}
var targetSpeed = new Vector3();
if (!lastRotRDictionary.ContainsKey(unit.Handle))
{
lastRotRDictionary.Add(unit.Handle, unit.RotationRad);
}
var straightTime = StraightTime(unit);
if (straightTime > 180)
{
lastRotRDictionary[unit.Handle] = unit.RotationRad;
}
lastRotRDictionary[unit.Handle] = unit.RotationRad;
if ((unit.ClassID == ClassID.CDOTA_Unit_Hero_StormSpirit || unit.ClassID == ClassID.CDOTA_Unit_Hero_Rubick)
&& unit.HasModifier("modifier_storm_spirit_ball_lightning"))
{
var ballLightning = unit.FindSpell("storm_spirit_ball_lightning", true);
var firstOrDefault =
ballLightning.AbilitySpecialData.FirstOrDefault(x => x.Name == "ball_lightning_move_speed");
if (firstOrDefault != null)
{
var ballSpeed = firstOrDefault.GetValue(ballLightning.Level - 1);
var newpredict = unit.Vector3FromPolarAngle() * (ballSpeed / 1000f);
targetSpeed = newpredict;
}
}
else
{
targetSpeed = unit.Vector3FromPolarAngle() * (unit.MovementSpeed / 1000f);
}
var v = unit.Position + (targetSpeed * delay);
return new Vector3(v.X, v.Y, 0);
}
示例4: CalculateReachTime
/// <summary>
/// </summary>
/// <param name="target"></param>
/// <param name="speed"></param>
/// <param name="dePos"></param>
/// <returns></returns>
public static float CalculateReachTime(Unit target, float speed, Vector3 dePos)
{
Vector3 targetSpeed;
if ((!SpeedDictionary.TryGetValue(target.Handle, out targetSpeed) || targetSpeed == new Vector3(0, 0, 0))
&& target.NetworkActivity == NetworkActivity.Move)
{
var rotSpeed = 0d;
if (RotSpeedDictionary.ContainsKey(target.Handle))
{
rotSpeed = RotSpeedDictionary[target.Handle];
}
targetSpeed = target.Vector3FromPolarAngle((float)rotSpeed) * (target.MovementSpeed) / 1000;
}
var a = Math.Pow(targetSpeed.X, 2) + Math.Pow(targetSpeed.Y, 2) - Math.Pow(speed / 1000, 2);
var b = 2 * (dePos.X * targetSpeed.X + dePos.Y * targetSpeed.Y);
var c = Math.Pow(dePos.X, 2) + Math.Pow(dePos.Y, 2);
return (float)((-b - Math.Sqrt(Math.Pow(b, 2) - 4 * a * c)) / (2 * a));
}
示例5: PredictXYZ
public static Vector3 PredictXYZ(Unit unit, float delay)
{
Vector3 vector3;
if ((!Prediction.SpeedDictionary.TryGetValue((float)((float)unit.Handle), out vector3) || vector3 == new Vector3(0f, 0f, 0f)) && unit.NetworkActivity == NetworkActivity.Move)
{
double item = 0;
if (Prediction.RotSpeedDictionary.ContainsKey((float)((float)unit.Handle)))
{
item = Prediction.RotSpeedDictionary[(float)((float)unit.Handle)];
}
vector3 = (unit.Vector3FromPolarAngle((float)item, 1f) * (float)unit.MovementSpeed) / 1000f;
}
if (Prediction.IsIdle(unit))
{
return unit.Position;
}
Vector3 position = unit.Position + (vector3 * delay);
return new Vector3(position.X, position.Y, 0f);
}