public static List <CustomRoute> GetCustomRoutes() { List <CustomRoute> routes = new List <CustomRoute>(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); string rt = ""; string[] vals; string[] spchar = new string[] { "," }; CustomRoute cr; for (int i = 1; i < 201; i++) { if (System.Configuration.ConfigurationManager.AppSettings.Get("customroute" + i.ToString()) != null) { rt = System.Configuration.ConfigurationManager.AppSettings.Get("customroute" + i.ToString()).Trim(); if (rt != "") { rt = rt.Replace(" ", ""); if (rt.Length == 0) { continue; } vals = rt.Split(spchar, StringSplitOptions.RemoveEmptyEntries); if (vals.Length == 3) { cr = new CustomRoute(); cr.Controller = vals[0]; cr.Action = vals[1]; cr.Path = vals[2]; routes.Add(cr); } } else { break; } } else { break; } } return(routes); }
private void SetRoute(CustomRoute customRoute, RouteValueDictionary routeValueDictionary = null) { var predefinedPageInfo = customRoute.PredefinedPage.GetAttribute <PredefinedPageInfoAttribute>(); _requestContext.RouteData.Values["controller"] = predefinedPageInfo.Controller; _requestContext.RouteData.Values["action"] = predefinedPageInfo.Action; if (routeValueDictionary == null) { return; } foreach (var routeValue in routeValueDictionary) { _requestContext.RouteData.Values[routeValue.Key] = routeValue.Value; } }
public static Route MapRoute(this RouteCollection routes, string name, string url, string excludeRouteValueNames, object defaults, object constraints, string[] namespaces) { if (routes == null) { throw new ArgumentNullException("routes"); } if (url == null) { throw new ArgumentNullException("url"); } Route item = new CustomRoute(url, new MvcRouteHandler(), excludeRouteValueNames) { Defaults = new RouteValueDictionary(defaults), Constraints = new RouteValueDictionary(constraints), DataTokens = new RouteValueDictionary() }; if ((namespaces != null) && (namespaces.Length > 0)) { item.DataTokens["Namespaces"] = namespaces; } routes.Add(name, item); return(item); }
public object Any(CustomRoute request) { return(request); }
private static async Task FollowTheYellowbrickroad(ISession session, CancellationToken cancellationToken, CustomRoute route, Navigation navi, EggWalker eggWalker, string prevRouteName) { var initialize = true; //Find closest point of route and it's index! var closestPoint = await CheckClosestAndMove(session, cancellationToken, route); long nextMaintenceStamp = 0; var sameRoute = true; while (sameRoute) { foreach (var wp in route.RoutePoints) { if (session.ForceMoveTo != null) { break; } if (initialize) { if (wp != closestPoint) { continue; } initialize = false; } if (prevRouteName != session.LogicSettings.CustomRouteName) { sameRoute = false; session.EventDispatcher.Send(new NoticeEvent() { Message = $"Route switched from {prevRouteName} to {session.LogicSettings.CustomRouteName}!" }); break; } session.State = BotState.Walk; var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, wp.Latitude, wp.Longitude); await navi.HumanPathWalking( session, wp, NextMoveSpeed(session), async() => { await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(session, cancellationToken); return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken, true); await PokeNearbyGym.Execute(session, cancellationToken); return(true); }, cancellationToken ); session.State = BotState.Idle; await eggWalker.ApplyDistance(distance, cancellationToken); if (nextMaintenceStamp >= DateTime.UtcNow.ToUnixTime() && session.Runtime.StopsHit < 100) { continue; } await MaintenanceTask.Execute(session, cancellationToken); nextMaintenceStamp = DateTime.UtcNow.AddMinutes(3).ToUnixTime(); } if (initialize) { initialize = false; } if (session.ForceMoveTo != null) { await ForceMoveTask.Execute(session, cancellationToken); closestPoint = await CheckClosestAndMove(session, cancellationToken, route); initialize = true; } } }
private static async Task <GeoCoordinate> CheckClosestAndMove(ISession session, CancellationToken cancellationToken, CustomRoute route) { var closestPoint = route.RoutePoints.OrderBy( x => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, x.Latitude, x.Longitude)).First(); var distToClosest = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, closestPoint.Latitude, closestPoint.Longitude); if (distToClosest > 10) { session.State = BotState.Walk; session.EventDispatcher.Send(new NoticeEvent() { Message = $"Found closest point at {closestPoint.Latitude} - {closestPoint.Longitude}, distance to that point: {distToClosest.ToString("N1")} meters, moving there!" }); await session.Navigation.Move(closestPoint, session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, async() => { if (session.LogicSettings.CatchWildPokemon) { // Catch normal map Pokemon await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(session, cancellationToken); } return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken, true); return(true); }, cancellationToken, session); session.State = BotState.Idle; } var nextPath = route.RoutePoints.Select(item => Tuple.Create(item.Latitude, item.Longitude)).ToList(); session.EventDispatcher.Send(new NextRouteEvent { Coords = nextPath }); return(closestPoint); }
private static async Task <GeoCoordinate> CheckClosestAndMove(ISession session, CancellationToken cancellationToken, CustomRoute route) { var closestPoint = route.RoutePoints.OrderBy( x => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, x.Latitude, x.Longitude)).First(); var distToClosest = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, closestPoint.Latitude, closestPoint.Longitude); var tries = 0; while (distToClosest > 15 && tries++ < 5) { session.State = BotState.Walk; session.EventDispatcher.Send(new NoticeEvent { Message = session.Translation.GetTranslation(TranslationString.FoundClosest, closestPoint.Latitude, closestPoint.Longitude, distToClosest.ToString("N1")) }); await session.Navigation.Move(closestPoint, session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax, async() => { if (session.LogicSettings.CatchWildPokemon) { // Catch normal map Pokemon await CatchNearbyPokemonsTask.Execute(session, cancellationToken); //Catch Incense Pokemon await CatchIncensePokemonsTask.Execute(session, cancellationToken); } return(true); }, async() => { await UseNearbyPokestopsTask.Execute(session, cancellationToken, true); return(true); }, cancellationToken, session); if (session.ForceMoveJustDone) { session.ForceMoveJustDone = false; tries = 0; } closestPoint = route.RoutePoints.OrderBy( x => LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, x.Latitude, x.Longitude)).First(); distToClosest = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude, session.Client.CurrentLongitude, closestPoint.Latitude, closestPoint.Longitude); session.State = BotState.Idle; } var nextPath = route.RoutePoints.Select(item => Tuple.Create(item.Latitude, item.Longitude)).ToList(); session.EventDispatcher.Send(new NextRouteEvent { Coords = nextPath }); return(closestPoint); }