示例#1
0
 /// <summary>
 /// 更新当前图形
 /// </summary>
 /// <param name="ms"></param>
 public override void Update()
 {
     if (Start != null && End != null)
     {
         if (this.ColumnType == 0)
         {
             var Radius = End.Distance(Start);
             this.DrawArcFill(Start, Radius, Radius);
         }
         else
         {
             List <Vector2D> points = new List <Vector2D>();
             var             v1     = start;
             var             v3     = end;
             var             v2     = new Vector2D(v1.X, v3.Y);
             var             v4     = new Vector2D(v3.X, v1.Y);
             points.Add(v1);
             points.Add(v2);
             points.Add(v3);
             points.Add(v4);
             points.Add(v1);
             this.DrawFill(points);
         }
     }
 }
示例#2
0
        /// <summary>
        ///     Returns the missile position after time time.
        /// </summary>
        public Vector2 GlobalGetMissilePosition(int time)
        {
            var t = Math.Max(0, Environment.TickCount + time - StartTick - SpellData.Delay);

            t = (int)Math.Max(0, Math.Min(End.Distance(Start), t * SpellData.MissileSpeed / 1000));
            return(Start + Direction * t);
        }
示例#3
0
 /// <summary>
 /// 更新当前图形
 /// </summary>
 /// <param name="ms"></param>
 public override void Update()
 {
     if (Start != null && End != null)
     {
         var Radius = End.Distance(Start);
         this.DrawArcFill(Start, Radius, Radius);
     }
 }
示例#4
0
        /// <summary>
        ///     Returns if the skillshot will hit the unit if the unit follows the path.
        /// </summary>
        public SafePathResult IsSafePath(List <Vector2> path,
                                         int timeOffset,
                                         int speed        = -1,
                                         int delay        = 0,
                                         Obj_AI_Base unit = null)
        {
            var Distance = 0f;

            timeOffset += Game.Ping / 2;

            speed = (speed == -1) ? (int)ObjectManager.Player.MoveSpeed : speed;

            if (unit == null)
            {
                unit = ObjectManager.Player;
            }

            var allIntersections = new List <FoundIntersection>();

            for (var i = 0; i <= path.Count - 2; i++)
            {
                var from = path[i];
                var to   = path[i + 1];
                var segmentIntersections = new List <FoundIntersection>();

                for (var j = 0; j <= Polygon.Points.Count - 1; j++)
                {
                    var sideStart = Polygon.Points[j];
                    var sideEnd   = Polygon.Points[j == (Polygon.Points.Count - 1) ? 0 : j + 1];

                    var intersection = from.Intersection(to, sideStart,
                                                         sideEnd);

                    if (intersection.Intersects)
                    {
                        segmentIntersections.Add(
                            new FoundIntersection(
                                Distance + intersection.Point.Distance(from),
                                (int)((Distance + intersection.Point.Distance(from)) * 1000 / speed),
                                intersection.Point, from));
                    }
                }

                var sortedList = segmentIntersections.OrderBy(o => o.Distance).ToList();
                allIntersections.AddRange(sortedList);

                Distance += from.Distance(to);
            }

            //Skillshot with missile.
            if (SpellData.Type == SkillShotType.SkillshotMissileLine ||
                SpellData.Type == SkillShotType.SkillshotMissileCone)
            {
                //Outside the skillshot
                if (IsSafe(ObjectManager.Player.ServerPosition.To2D()))
                {
                    //No intersections -> Safe
                    if (allIntersections.Count == 0)
                    {
                        return(new SafePathResult(true, new FoundIntersection()));
                    }

                    for (var i = 0; i <= allIntersections.Count - 1; i = i + 2)
                    {
                        var enterIntersection           = allIntersections[i];
                        var enterIntersectionProjection = enterIntersection.Point.ProjectOn(Start, End).SegmentPoint;

                        //Intersection with no exit point.
                        if (i == allIntersections.Count - 1)
                        {
                            var missilePositionOnIntersection =
                                GetMissilePosition(enterIntersection.Time - timeOffset);
                            return
                                (new SafePathResult(
                                     (End.Distance(missilePositionOnIntersection) + 50 <=
                                      End.Distance(enterIntersectionProjection)) &&
                                     ObjectManager.Player.MoveSpeed < SpellData.MissileSpeed, allIntersections[0]));
                        }


                        var exitIntersection           = allIntersections[i + 1];
                        var exitIntersectionProjection = exitIntersection.Point.ProjectOn(Start, End).SegmentPoint;

                        var missilePosOnEnter = GetMissilePosition(enterIntersection.Time - timeOffset);
                        var missilePosOnExit  = GetMissilePosition(exitIntersection.Time + timeOffset);

                        //Missile didnt pass.
                        if (missilePosOnEnter.Distance(End) + 50 > enterIntersectionProjection.Distance(End))
                        {
                            if (missilePosOnExit.Distance(End) <= exitIntersectionProjection.Distance(End))
                            {
                                return(new SafePathResult(false, allIntersections[0]));
                            }
                        }
                    }

                    return(new SafePathResult(true, allIntersections[0]));
                }
                //Inside the skillshot.
                if (allIntersections.Count == 0)
                {
                    return(new SafePathResult(false, new FoundIntersection()));
                }

                if (allIntersections.Count > 0)
                {
                    //Check only for the exit point
                    var exitIntersection           = allIntersections[0];
                    var exitIntersectionProjection = exitIntersection.Point.ProjectOn(Start, End).SegmentPoint;

                    var missilePosOnExit = GetMissilePosition(exitIntersection.Time + timeOffset);
                    if (missilePosOnExit.Distance(End) <= exitIntersectionProjection.Distance(End))
                    {
                        return(new SafePathResult(false, allIntersections[0]));
                    }
                }
            }


            if (IsSafe(ObjectManager.Player.ServerPosition.To2D()))
            {
                if (allIntersections.Count == 0)
                {
                    return(new SafePathResult(true, new FoundIntersection()));
                }

                if (SpellData.DontCross)
                {
                    return(new SafePathResult(false, allIntersections[0]));
                }
            }
            else
            {
                if (allIntersections.Count == 0)
                {
                    return(new SafePathResult(false, new FoundIntersection()));
                }
            }

            var timeToExplode = (SpellData.DontAddExtraDuration ? 0 : SpellData.ExtraDuration) + SpellData.Delay +
                                (int)(1000 * Start.Distance(End) / SpellData.MissileSpeed) -
                                (Environment.TickCount - StartTick);


            var myPositionWhenExplodes = path.PositionAfter(timeToExplode, speed, delay);

            if (!IsSafe(myPositionWhenExplodes))
            {
                return(new SafePathResult(false, allIntersections[0]));
            }

            var myPositionWhenExplodesWithOffset = path.PositionAfter(timeToExplode, speed, timeOffset);

            return(new SafePathResult(IsSafe(myPositionWhenExplodesWithOffset), allIntersections[0]));
        }