public override async Task <PlayerUpdateResponse> Walk(IGeoLocation targetLocation,
                                                               Func <Task> functionExecutedWhileWalking, ISession session, CancellationToken cancellationToken,
                                                               double walkSpeed = 0.0)
        {
            GetMapzenInstance(session);
            var sourceLocation = new GeoCoordinate(
                _client.CurrentLatitude,
                _client.CurrentLongitude,
                _client.CurrentAltitude
                );
            var        destinaionCoordinate = new GeoCoordinate(targetLocation.Latitude, targetLocation.Longitude);
            MapzenWalk mapzenWalk           = _mapzenDirectionsService.GetDirections(sourceLocation, destinaionCoordinate);

            if (mapzenWalk == null)
            {
                return(await RedirectToNextFallbackStrategy(
                           session.LogicSettings,
                           targetLocation,
                           functionExecutedWhileWalking,
                           session,
                           cancellationToken
                           ));
            }

            base.OnStartWalking(session, targetLocation, mapzenWalk.Distance);
            List <GeoCoordinate> points = mapzenWalk.Waypoints;

            return(await DoWalk(points, session, functionExecutedWhileWalking, sourceLocation,
                                destinaionCoordinate, cancellationToken, walkSpeed));
        }
        public override async Task <PlayerUpdateResponse> Walk(GeoCoordinate targetLocation, Func <Task> functionExecutedWhileWalking, ISession session, CancellationToken cancellationToken, double walkSpeed = 0.0)
        {
            GetMapzenInstance(session);
            var        sourceLocation = new GeoCoordinate(_client.CurrentLatitude, _client.CurrentLongitude, _client.CurrentAltitude);
            MapzenWalk mapzenWalk     = _mapzenDirectionsService.GetDirections(sourceLocation, targetLocation);

            if (mapzenWalk == null)
            {
                return(await RedirectToNextFallbackStrategy(session.LogicSettings, targetLocation, functionExecutedWhileWalking, session, cancellationToken));
            }

            session.EventDispatcher.Send(new FortTargetEvent {
                Name = FortInfo.Name, Distance = mapzenWalk.Distance, Route = GetWalkStrategyId()
            });
            List <GeoCoordinate> points = mapzenWalk.Waypoints;

            return(await DoWalk(points, session, functionExecutedWhileWalking, sourceLocation, targetLocation, cancellationToken, walkSpeed));
        }
        public MapzenWalk GetDirections(GeoCoordinate sourceLocation, GeoCoordinate destLocation)
        {
            WebRequest request = WebRequest.Create(GetUrl(sourceLocation, destLocation));

            request.Credentials = CredentialCache.DefaultCredentials;

            try
            {
                using (WebResponse response = request.GetResponse())
                {
                    using (Stream dataStream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(dataStream))
                        {
                            string responseFromServer = reader.ReadToEnd();
                            return(MapzenWalk.Get(responseFromServer, sourceLocation, destLocation));
                        }
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }