/// <summary> /// Connects all points. /// </summary> public void ConnectAllPoints() { try { if (GlobalVariables.Debug) { Console.WriteLine(@"GridGenerator.Cs > ConnectAllPoints()"); } // foreach dash foreach (var x in this.Grid.Connections.Where(x => x is YasuoDashConnection).ToList()) { var path = GlobalVariables.Player.GetPath(x.End.Position, this.EndPosition); var firstpoint = x.End; for (var i = 0; i < path.Count() - 1; i++) { var start = new Point(path[i]); if (i == 0) { start = firstpoint; } var end = new Point(path[i + 1]); if (i == path.Count() - 2) { end = this.EndPoint; } var connection = new WalkConnection(start, end); if (!this.Grid.Connections.Contains(connection)) { this.Grid.Connections.Add(connection); } } } } catch (Exception ex) { Console.WriteLine(@"[GridManager]: " + ex); } }
// TODO: PRIORITY MEDIUM > Walk behind minion to dash over it /// <summary> /// Creates a new unique grid for every unit in dash range /// </summary> public void Generate() { try { this.SoftReset(); if (GlobalVariables.Debug) { Console.WriteLine(@"GridGenerator.Cs > Initialize()"); } // Setting up the first points foreach (var unit in this.Units.Where( x => Geometry.Distance(x, this.BasePoint.Position) <= GlobalVariables.Spells[SpellSlot.E].Range) ) { var pointToAdd = new Point(new Dash(GlobalVariables.Player.ServerPosition, unit).EndPosition); this.sharedPoints.Add(pointToAdd); this.sharedConnections.Add(new YasuoDashConnection(this.BasePoint, pointToAdd, unit)); } // Connecting StartPoint to EndPoint var path2 = GlobalVariables.Player.GetPath(this.BasePoint.Position, this.EndPosition); if (path2 != null && path2.Length > 0) { for (var i = 0; i < path2.Count() - 1; i++) { var start = new Point(path2[i]); if (i == 0) { start = this.BasePoint; } var end = new Point(path2[i + 1]); if (i == path2.Count() - 2) { end = this.EndPoint; } var connection = new WalkConnection(start, end); if (!this.sharedConnections.Contains(connection)) { this.sharedConnections.Add(connection); } } } else { this.sharedConnections.Add( new SimpleConnection <Point>( this.BasePoint, this.EndPoint, this.BasePoint.Position.Distance(this.EndPoint.Position) / GlobalVariables.Player.MoveSpeed)); } // Starts generating possible pathes for (var i = 0; i < this.PathDeepness; i++) { if (!this.sharedPoints.Any()) { break; } foreach (var point in this.sharedPoints.ToList()) { var localBlacklist = this.Backtrace(point, this.MaxConnections); var unitCount = this.Units.Where( unit => Geometry.Distance(unit, point.Position) <= GlobalVariables.Spells[SpellSlot.E].Range) .Count(unit => !localBlacklist.Contains(unit)); // Remove point from list and continue because there are no valid dashes available around that point if (unitCount == 0) { if (GlobalVariables.Debug) { Console.WriteLine( @"[GridGenerator] Removing Point because no dashes are available for that point anymore"); } this.sharedPoints.Remove(point); continue; } this.ProcessPoint(point, localBlacklist); this.sharedPoints.Remove(point); } } this.sharedPoints.Add(this.EndPoint); this.Grid = new Grid <Point, ConnectionBase <Point> >( this.sharedConnections, this.BasePoint, this.EndPoint); } catch (Exception ex) { this.SoftReset(); Console.WriteLine(ex); } }