当前位置: 首页>>代码示例>>C#>>正文


C# Unit.Vector3FromPolarAngle方法代码示例

本文整理汇总了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);
 }
开发者ID:spyware293,项目名称:Ensage.Common,代码行数:27,代码来源:Prediction.cs

示例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);
 }
开发者ID:spyware293,项目名称:Ensage.Common,代码行数:11,代码来源:Prediction.cs

示例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);
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:53,代码来源:Prediction.cs

示例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));
 }
开发者ID:spyware293,项目名称:Ensage.Common,代码行数:24,代码来源:Prediction.cs

示例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);
 }
开发者ID:NadeHouse,项目名称:Pudge-Plus,代码行数:19,代码来源:GlobalClasses.cs


注:本文中的Unit.Vector3FromPolarAngle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。