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


C# SkillshotType类代码示例

本文整理汇总了C#中SkillshotType的典型用法代码示例。如果您正苦于以下问题:C# SkillshotType类的具体用法?C# SkillshotType怎么用?C# SkillshotType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SkillshotType类属于命名空间,在下文中一共展示了SkillshotType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCastMinionsPredictedPositions

        public static List<Vector2> GetCastMinionsPredictedPositions(List<Obj_AI_Base> minions,
            float delay,
            float width,
            float speed,
            Vector3 from,
            float range,
            bool collision,
            SkillshotType stype,
            Vector3 rangeCheckFrom = new Vector3())
        {
            var result = new List<Vector2>();
            from = from.To2D().IsValid() ? from : ObjectManager.Player.ServerPosition;
            foreach (var minion in minions)
            {
                var pos = Prediction.GetPrediction(new PredictionInput
                {
                    Unit = minion,
                    Delay = delay,
                    Radius = width,
                    Speed = speed,
                    From = from,
                    Range = range,
                    Collision = collision,
                    Type = stype,
                    RangeCheckFrom = rangeCheckFrom
                });

                if (pos.Hitchance >= HitChance.High)
                {
                    result.Add(pos.CastPosition.To2D());
                }
            }

            return result;
        }
开发者ID:Merc491,项目名称:GoodGuyJodu,代码行数:35,代码来源:YasMath.cs

示例2: SpellData

 public SpellData(string baseSkinName, string spellName, SpellSlot slot, SkillshotType type, float delay, float range,
     float radius, float missileSpeed, bool addHitbox, bool fixedRange, int defaultDangerValue)
 {
     BaseSkinName = baseSkinName;
     SpellName = spellName;
     Slot = slot;
     Type = type;
     Delay = delay;
     Range = range;
     _radius = radius;
     MissileSpeed = missileSpeed;
     AddHitbox = addHitbox;
     FixedRange = fixedRange;
     DangerValue = defaultDangerValue;
 }
开发者ID:WTayllor,项目名称:L-,代码行数:15,代码来源:SpellData.cs

示例3: WaypointAnlysis

        /// <summary>
        /// Calculates cast position with target's path
        /// </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>
        /// <returns></returns>
        internal static Result WaypointAnlysis(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, Vector2 from, float moveSpeed = 0, bool isDash = false)
        {
            if (moveSpeed == 0)
                moveSpeed = target.MoveSpeed;

            Result result = new Result();

            float flyTimeMax = 0f;

            if (missileSpeed != 0) //skillshot with a missile
                flyTimeMax = range / missileSpeed;

            float tMin = delay + Game.Ping / 2000f + SpellDelay / 1000f;
            float tMax = flyTimeMax + delay + Game.Ping / 1000f + SpellDelay / 1000f;
            float pathTime = 0f;
            int[] pathBounds = new int[] { -1, -1 };

            //find bounds
            for (int i = 0; i < path.Count - 1; i++)
            {
                float t = path[i + 1].Distance(path[i]) / moveSpeed;

                if (pathTime <= tMin && pathTime + t >= tMin)
                    pathBounds[0] = i;
                if (pathTime <= tMax && pathTime + t >= tMax)
                    pathBounds[1] = i;

                if (pathBounds[0] != -1 && pathBounds[1] != -1)
                    break;

                pathTime += t;
            }

            //calculate cast & unit position
            if (pathBounds[0] != -1 && pathBounds[1] != -1)
            {
                for (int k = pathBounds[0]; k <= pathBounds[1]; k++)
                {
                    Vector2 direction = (path[k + 1] - path[k]).Normalized();
                    float distance = width;
                    if (predMenu.Item("SPREDWPANALYSIS").GetValue<StringList>().SelectedIndex == 0)
                        distance = target.BoundingRadius;

                    int steps = (int)Math.Floor(path[k].Distance(path[k + 1]) / distance);
                    //split & anlyse current path
                    for (int i = 0; i < steps; i++)
                    {
                        Vector2 pA = path[k] + (direction * distance * i);
                        Vector2 pB = path[k] + (direction * distance * (i + 1));
                        Vector2 center = (pA + pB) / 2f;

                        float flytime = missileSpeed != 0 ? from.Distance(center) / missileSpeed : 0f;
                        float t = flytime + delay + Game.Ping / 1000f + SpellDelay / 1000f;

                        Vector2 currentPosition = isDash ? target.Position.To2D() : target.ServerPosition.To2D();

                        float arriveTimeA = currentPosition.Distance(pA) / moveSpeed;
                        float arriveTimeB = currentPosition.Distance(pB) / moveSpeed;

                        if (Math.Min(arriveTimeA, arriveTimeB) <= t && Math.Max(arriveTimeA, arriveTimeB) >= t)
                        {
                            result.HitChance = GetHitChance(t, avgt, movt, avgp);
                            result.CastPosition = center;
                            result.UnitPosition = center + (direction * (t - Math.Min(arriveTimeA, arriveTimeB)) * moveSpeed);
                            result.CollisionResult = Collision.GetCollisions(from, result.CastPosition, width, delay, missileSpeed);
                            return result;
                        }
                    }

                    if (steps == 0)
                    {
                        float flytime = missileSpeed != 0 ? from.Distance(path[pathBounds[1]]) / missileSpeed : 0f;
                        float t = flytime + delay + Game.Ping / 2000f + SpellDelay / 1000f;
                        result.HitChance = GetHitChance(t, avgt, movt, avgp);
                        result.CastPosition = path[pathBounds[1]];
                        result.UnitPosition = path[pathBounds[1]];
                        result.CollisionResult = Collision.GetCollisions(from, result.CastPosition, width, delay, missileSpeed);
                        return result;
                    }
                }
            }

            result.HitChance = HitChance.Impossible;

//.........这里部分代码省略.........
开发者ID:MrWenzoxfs,项目名称:elobuddy,代码行数:101,代码来源:Prediction.cs

示例4: 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)
        {
            Result result = new Result();

            if (target.IsDashing())
            {
                var dashInfo = target.GetDashInfo();
                if (dashInfo.IsBlink)
                {
                    result.HitChance = HitChance.Impossible;
                    return result;
                }

                //define hitboxes
                var dashHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(dashInfo.StartPos, dashInfo.EndPos + (dashInfo.EndPos - dashInfo.StartPos).Normalized() * 500, target.BoundingRadius * 2));
                var myHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(from, from == ObjectManager.Player.ServerPosition.To2D() ? ObjectManager.Player.BoundingRadius : width));

                if (ClipperWrapper.IsIntersects(myHitBox, dashHitBox))
                {
                    result.HitChance = HitChance.Dashing;
                    result.CastPosition = target.ServerPosition.To2D();
                    result.UnitPosition = result.CastPosition;
                    result.CollisionResult = Collision.GetCollisions(from, result.CastPosition, width, delay, missileSpeed);

                    //check collisions
                    if (collisionable && result.CollisionResult.Objects.HasFlag(Collision.Flags.Minions))
                        result.HitChance = HitChance.Collision;

                    return result;
                }

                result.CastPosition = GetFastUnitPosition(target, dashInfo.Path, delay, missileSpeed, from, dashInfo.Speed);
                result.HitChance = HitChance.Dashing;

                //check range
                if (result.CastPosition.Distance(from) > range)
                    result.HitChance = HitChance.OutOfRange;

                //check collisions
                if (collisionable && (result.CollisionResult.Objects.HasFlag(Collision.Flags.Minions) || result.CollisionResult.Objects.HasFlag(Collision.Flags.YasuoWall)))
                    result.HitChance = HitChance.Collision;
            }
            else
                result.HitChance = HitChance.Impossible;
            return result;
        }
开发者ID:MrWenzoxfs,项目名称:elobuddy,代码行数:58,代码来源:Prediction.cs

示例5: 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)
        {
            Result result = new Result();
            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.CollisionResult = Collision.GetCollisions(from, result.CastPosition, width, delay, missileSpeed);

                if (collisionable && result.CollisionResult.Objects.HasFlag(Collision.Flags.Minions))
                    result.HitChance = HitChance.Collision;

                if (from.Distance(result.CastPosition) > range - GetArrivalTime(from.Distance(result.CastPosition), delay, missileSpeed) * target.MoveSpeed * (100 - predMenu.Item("SPREDMAXRANGEIGNORE").GetValue<Slider>().Value) / 100f)
                    result.HitChance = HitChance.OutOfRange;

                return result;
            }

            if (target is Obj_AI_Hero)
                result.HitChance = GetHitChance(t - Utility.LeftImmobileTime(target), ((Obj_AI_Hero)target).AvgMovChangeTime(), 0, 0);
            else
                result.HitChance = HitChance.High;

            //check collisions
            if (collisionable && result.CollisionResult.Objects.HasFlag(Collision.Flags.Minions))
                result.HitChance = HitChance.Collision;

            //check range
            if (from.Distance(result.CastPosition) > range - GetArrivalTime(from.Distance(result.CastPosition), delay, missileSpeed) * target.MoveSpeed * (100 - predMenu.Item("SPREDMAXRANGEIGNORE").GetValue<Slider>().Value) / 100f)
                result.HitChance = HitChance.OutOfRange;

            return result;
        }
开发者ID:MrWenzoxfs,项目名称:elobuddy,代码行数:55,代码来源:Prediction.cs

示例6: 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="from">Spell casted position</param>
 /// <returns>Prediction result as <see cref="Prediction.Result"/></returns>
 internal static Result GetPrediction(Obj_AI_Hero target, float width, float delay, float missileSpeed, float range, bool collisionable, SkillshotType type)
 {
     return GetPrediction(target, width, delay, missileSpeed, range, collisionable, type, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), ObjectManager.Player.ServerPosition.To2D(), ObjectManager.Player.ServerPosition.To2D());
 }
开发者ID:MrWenzoxfs,项目名称:elobuddy,代码行数:16,代码来源:Prediction.cs

示例7: SetSkillshot

 public void SetSkillshot(int delay, int width, int speed, SkillshotType skillshotType, Vector3 sourcePosition = new Vector3(), Vector3 rangeCheckPosition = new Vector3())
 {
     Delay = delay;
     Width = width;
     Speed = speed;
     SkillShotType = skillshotType;
     SourcePosition = sourcePosition;
     RangeCheckPosition = rangeCheckPosition;
     IsSkillshot = true;
 }
开发者ID:hanifzarina,项目名称:EloBuddy,代码行数:10,代码来源:Spell.cs

示例8: 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;
        }
开发者ID:ShineSharp,项目名称:LeagueSharp,代码行数:45,代码来源:Prediction.cs

示例9: SetSkillshot

        /// <summary>
        ///     Sets the Spell Data to Skill-shot data.
        /// </summary>
        /// <param name="collision">
        ///     Spell Collision Flag
        /// </param>
        /// <param name="type">
        ///     Skill-shot Type
        /// </param>
        /// <param name="fromVector3">
        ///     From Vector3 Source
        /// </param>
        /// <param name="rangeCheckFromVector3">
        ///     Range Check From Vector3 Source
        /// </param>
        /// <returns>
        ///     The <see cref="Spell" />.
        /// </returns>
        public Spell SetSkillshot(
            bool collision,
            SkillshotType type,
            Vector3 fromVector3 = default(Vector3),
            Vector3 rangeCheckFromVector3 = default(Vector3))
        {
            this.From = fromVector3;
            this.Collision = collision;
            this.Type = type;
            this.RangeCheckFrom = rangeCheckFromVector3;
            this.IsSkillshot = true;

            return this;
        }
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:32,代码来源:Spell.cs

示例10: Spells

 public Spells(SpellSlot Spellslot, SkillshotType Skillshottype, float Range, float Delay, float Radius, bool Collision, float Speed = 4000000, float ExtraRange = 0)
 {
     spellslot = Spellslot;
     delay = Delay;
     radius = Radius;
     speed = Speed;
     range = Range;
     extrarange = ExtraRange;
     collision = Collision;
     skillshottype = Skillshottype;
     MinHitChance = HitChances.VeryLow;
 }
开发者ID:uio25371555,项目名称:Leaguesharp-3,代码行数:12,代码来源:Spells.cs

示例11: Input

 public Input(Obj_AI_Base _target, float delay, float speed, float radius, float range, bool collision, SkillshotType type, Vector3 _from, Vector3 _rangeCheckFrom)
 {
     Target = _target;
     SpellDelay = delay;
     SpellMissileSpeed = speed;
     SpellWidth = radius;
     SpellRange = range;
     SpellCollisionable = collision;
     SpellSkillShotType = type;
     Path = Target.GetWaypoints();
     if (Target is Obj_AI_Hero)
     {
         Obj_AI_Hero t = Target as Obj_AI_Hero;
         AvgReactionTime = t.AvgMovChangeTime();
         LastMovChangeTime = t.LastMovChangeTime();
         AvgPathLenght = t.AvgPathLenght();
         LastAngleDiff = t.LastAngleDiff();
     }
     else
     {
         AvgReactionTime = 0;
         LastMovChangeTime = 0;
         AvgPathLenght = 0;
         LastAngleDiff = 0;
     }
     From = _from;
     RangeCheckFrom = _rangeCheckFrom;
 }
开发者ID:ShineSharp,项目名称:LeagueSharp,代码行数:28,代码来源:Prediction.cs

示例12: 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;
            }
//.........这里部分代码省略.........
开发者ID:ShineSharp,项目名称:LeagueSharp,代码行数:101,代码来源:Prediction.cs

示例13: SetSkillshot

 public void SetSkillshot(float delay,
     float width,
     float speed,
     bool collision,
     SkillshotType type,
     Vector3 from = new Vector3(),
     Vector3 rangeCheckFrom = new Vector3())
 {
     Delay = delay;
     Width = width;
     Speed = speed;
     From = from;
     Collision = collision;
     Type = type;
     RangeCheckFrom = rangeCheckFrom;
     IsSkillshot = true;
 }
开发者ID:qktlfflzk,项目名称:Backup5.4,代码行数:17,代码来源:Spell.cs

示例14: WaypointAnlysis

        /// <summary>
        ///     Calculates cast position with target's path
        /// </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>
        /// <returns></returns>
        internal static Result WaypointAnlysis(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, float moveSpeed = 0, bool isDash = false)
        {
            if (moveSpeed == 0)
                moveSpeed = target.MoveSpeed;

            var result = new Result {Unit = target};

            var flyTimeMax = 0f;

            if (missileSpeed != 0) //skillshot with a missile
                flyTimeMax = range/missileSpeed;

            var tMin = delay + Game.Ping/2000f + ConfigMenu.SpellDelay/1000f;
            var tMax = flyTimeMax + delay + Game.Ping/1000f + ConfigMenu.SpellDelay/1000f;
            var pathTime = 0f;
            int[] pathBounds = {-1, -1};

            //find bounds
            for (var i = 0; i < path.Count - 1; i++)
            {
                var t = path[i + 1].LSDistance(path[i])/moveSpeed;

                if (pathTime <= tMin && pathTime + t >= tMin)
                    pathBounds[0] = i;
                if (pathTime <= tMax && pathTime + t >= tMax)
                    pathBounds[1] = i;

                if (pathBounds[0] != -1 && pathBounds[1] != -1)
                    break;

                pathTime += t;
            }

            //calculate cast & unit position
            if (pathBounds[0] != -1 && pathBounds[1] != -1)
            {
                for (var k = pathBounds[0]; k <= pathBounds[1]; k++)
                {
                    var direction = (path[k + 1] - path[k]).LSNormalized();
                    var distance = width;
                    var extender = target.BoundingRadius;

                    if (type == SkillshotType.SkillshotLine)
                        extender = width;

                    var steps = (int) Math.Floor(path[k].LSDistance(path[k + 1])/distance);
                    //split & anlyse current path
                    for (var i = 1; i < steps - 1; i++)
                    {
                        var pCenter = path[k] + direction*distance*i;
                        var pA = pCenter - direction*extender;
                        var pB = pCenter + direction*extender;

                        var flytime = missileSpeed != 0 ? from.LSDistance(pCenter)/missileSpeed : 0f;
                        var t = flytime + delay + Game.Ping/2000f + ConfigMenu.SpellDelay/1000f;

                        var currentPosition = target.ServerPosition.LSTo2D();

                        var arriveTimeA = currentPosition.LSDistance(pA)/moveSpeed;
                        var arriveTimeB = currentPosition.LSDistance(pB)/moveSpeed;

                        if (Math.Min(arriveTimeA, arriveTimeB) <= t && Math.Max(arriveTimeA, arriveTimeB) >= t)
                        {
                            result.HitChance = GetHitChance(t, avgt, movt, avgp, anglediff);
                            result.CastPosition = pCenter;
                            result.UnitPosition = pCenter;
                                //+ (direction * (t - Math.Min(arriveTimeA, arriveTimeB)) * moveSpeed);
                            return result;
                        }
                    }
                }
            }

            result.HitChance = HitChance.Impossible;
            result.CastPosition = target.ServerPosition.LSTo2D();

            return result;
        }
开发者ID:Xelamats,项目名称:PortAIO,代码行数:96,代码来源:Prediction.cs

示例15: WaypointAnlysis

        /// <summary>
        /// Calculates cast position with target's path
        /// </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>
        /// <returns></returns>
        internal static Result WaypointAnlysis(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, float moveSpeed = 0, bool isDash = false)
        {
            if (moveSpeed == 0)
                moveSpeed = target.MoveSpeed;

            Result result = new Result();

            float flyTimeMax = 0f;

            if (missileSpeed != 0) //skillshot with a missile
                flyTimeMax = range / missileSpeed;

            float tMin = delay + Game.Ping / 2000f + SpellDelay / 1000f;
            float tMax = flyTimeMax + delay + Game.Ping / 1000f + SpellDelay / 1000f;
            float pathTime = 0f;
            int[] pathBounds = new int[] { -1, -1 };

            //find bounds
            for (int i = 0; i < path.Count - 1; i++)
            {
                float t = path[i + 1].Distance(path[i]) / moveSpeed;

                if (pathTime <= tMin && pathTime + t >= tMin)
                    pathBounds[0] = i;
                if (pathTime <= tMax && pathTime + t >= tMax)
                    pathBounds[1] = i;

                if (pathBounds[0] != -1 && pathBounds[1] != -1)
                    break;

                pathTime += t;
            }

            //calculate cast & unit position
            if (pathBounds[0] != -1 && pathBounds[1] != -1)
            {
                for (int k = pathBounds[0]; k <= pathBounds[1]; k++)
                {
                    Vector2 direction = (path[k + 1] - path[k]).Normalized();
                    float distance = width;
                    float extender = target.BoundingRadius;

                    if (type == SkillshotType.SkillshotLine)
                        extender = width;

                    int steps = (int)Math.Floor(path[k].Distance(path[k + 1]) / distance);
                    //split & anlyse current path
                    for (int i = 1; i < steps - 1; i++)
                    {
                        Vector2 pCenter = path[k] + (direction * distance * i);
                        Vector2 pA = pCenter - (direction * extender);
                        Vector2 pB = pCenter + (direction * extender);

                        float flytime = missileSpeed != 0 ? from.Distance(pCenter) / missileSpeed : 0f;
                        float t = flytime + delay + Game.Ping / 2000f + SpellDelay / 1000f;

                        Vector2 currentPosition = target.ServerPosition.To2D();

                        float arriveTimeA = currentPosition.Distance(pA) / moveSpeed;
                        float arriveTimeB = currentPosition.Distance(pB) / moveSpeed;

                        if (Math.Min(arriveTimeA, arriveTimeB) <= t && Math.Max(arriveTimeA, arriveTimeB) >= t)
                        {
                            result.HitChance = GetHitChance(t, avgt, movt, avgp, anglediff);
                            result.CastPosition = pCenter;
                            result.UnitPosition = pCenter; //+ (direction * (t - Math.Min(arriveTimeA, arriveTimeB)) * moveSpeed);
                            /*if (currentPosition.IsBetween(ObjectManager.Player.ServerPosition.To2D(), result.CastPosition))
                            {
                                result.CastPosition = currentPosition;
                                Console.WriteLine("corrected");
                            }*/
                            result.CollisionResult = Collision.GetCollisions(from, result.CastPosition, width, delay, missileSpeed);
                            return result;
                        }
                    }
                }
            }

            result.HitChance = HitChance.Impossible;

            return result;
        }
开发者ID:mirinsharp,项目名称:Leaguesharp,代码行数:98,代码来源:Prediction.cs


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