예제 #1
0
 /// <summary>
 /// Logs the user out by clearing data and timers
 /// </summary>
 public static void DoLogout()
 {
     // Clear stored token
     SettingsService.Instance.PtcAuthToken    = null;
     SettingsService.Instance.GoogleAuthToken = null;
     _mapUpdateTimer?.Stop();
     _mapUpdateTimer = null;
     _geolocator     = null;
     CatchablePokemons.Clear();
     NearbyPokemons.Clear();
     NearbyPokestops.Clear();
 }
예제 #2
0
 /// <summary>
 ///     Logs the user out by clearing data and timers
 /// </summary>
 public static void DoLogout()
 {
     // Clear stored token
     SettingsService.Instance.AccessTokenString = null;
     if (!SettingsService.Instance.RememberLoginData)
     {
         SettingsService.Instance.UserCredentials = null;
     }
     _heartbeat?.StopDispatcher();
     if (_geolocator != null)
     {
         _geolocator.PositionChanged -= GeolocatorOnPositionChanged;
     }
     _geolocator = null;
     _lastGeopositionMapObjectsRequest = null;
     CatchablePokemons?.Clear();
     NearbyPokemons?.Clear();
     NearbyPokestops?.Clear();
 }
예제 #3
0
        /// <summary>
        /// Updates catcheable and nearby Pokemons + Pokestops.
        /// We're using a single method so that we don't need two separate calls to the server, making things faster.
        /// </summary>
        /// <returns></returns>
        private static async Task UpdateMapObjects()
        {
            // Get all map objects from server
            var mapObjects = (await GetMapObjects(Geoposition)).Item1;
            // Replace data with the new ones
            var catchableTmp = new List <MapPokemon>(mapObjects.MapCells.SelectMany(i => i.CatchablePokemons));

            Logger.Write($"Found {catchableTmp.Count} catchable pokemons");
            if (catchableTmp.Count != CatchablePokemons.Count)
            {
                MapPokemonUpdated?.Invoke(null, null);
            }
            CatchablePokemons.Clear();
            foreach (var pokemon in catchableTmp)
            {
                CatchablePokemons.Add(new MapPokemonWrapper(pokemon));
            }
            var nearbyTmp = new List <NearbyPokemon>(mapObjects.MapCells.SelectMany(i => i.NearbyPokemons));

            Logger.Write($"Found {nearbyTmp.Count} nearby pokemons");
            NearbyPokemons.Clear();
            foreach (var pokemon in nearbyTmp)
            {
                NearbyPokemons.Add(pokemon);
            }
            // Retrieves PokeStops but not Gyms
            var pokeStopsTmp =
                new List <FortData>(mapObjects.MapCells.SelectMany(i => i.Forts)
                                    .Where(i => i.Type == FortType.Checkpoint));

            Logger.Write($"Found {pokeStopsTmp.Count} nearby PokeStops");
            NearbyPokestops.Clear();
            foreach (var pokestop in pokeStopsTmp)
            {
                NearbyPokestops.Add(new FortDataWrapper(pokestop));
            }
            Logger.Write("Finished updating map objects");
        }