예제 #1
0
        public static float GetClosestDistanceApproach(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist)
        {
            var walkDir = (pos - heroPos).Normalized();
            var zVector = new Vector2(0, 0);

            if (spell.info.spellType == SpellType.Line)
            {
                var spellPos = SpellDetector.GetCurrentSpellPosition(spell, true, delay);

                Vector2 cPos1, cPos2;

                var cpa = MathUtilsCPA.CPAPoints(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed, out cPos1, out cPos2);

                if (cpa < myHero.BoundingRadius + spell.info.radius + extraDist)
                {
                    if (cPos2.Distance(spell.startPos) > spell.info.range + myHero.BoundingRadius)
                    {
                        return(1); //500
                    }

                    return(0);
                }

                return(cpa - (myHero.BoundingRadius + GetSpellRadius(spell) + extraDist));
                //return MathUtils.ClosestTimeOfApproach(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed);
            }
            else if (spell.info.spellType == SpellType.Circular)
            {
                /*var spellHitTime = Math.Max(0, spell.endTime - Evade.GetTickCount());  //extraDelay
                 * var walkRange = heroPos.Distance(pos);
                 * var predictedRange = speed * (spellHitTime / 1000);
                 * var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos
                 *
                 * return Math.Max(0,tHeroPos.Distance(spell.endPos) - (GetSpellRadius(spell) + myHero.BoundingRadius + extraDist)); //+ dodgeBuffer
                 */
            }

            return(1);
        }