private void Map_Update(object sender, EventArgs e) { var map = sender as Map; if (map == null) { return; } var wildPokemons = map.Cells.SelectMany(c => c.WildPokemons).Select(p => new SpawnedPokemon(p, Configuration.Name)); foreach (var pokemon in wildPokemons) { PokemonHandler.HandleSpawnedPokemon(pokemon); } var catchablePokemons = map.Cells.SelectMany(c => c.CatchablePokemons).Select(p => new SpawnedPokemon(p, Configuration.Name)); foreach (var pokemon in catchablePokemons) { PokemonHandler.HandleSpawnedPokemon(pokemon); } if (Configuration.ProcessNearbyPokemon) { var nearbyPokemons = map.Cells.SelectMany(c => c.NearbyPokemons).ToList(); foreach (var pokemon in nearbyPokemons) { PokemonHandler.HandleNearbyPokemon(pokemon); } } if (Configuration.ProcessGyms) { var gyms = map.Cells.SelectMany(x => x.Forts).Where(x => x.Type == FortType.Gym).ToList(); foreach (var gym in gyms) { GymHandler.Handle(gym); } } var nextPosition = Walker.GetNextPosition(); Session.Player.SetCoordinates(nextPosition.Latitude, nextPosition.Longitude); }
public PokemonGoService() { var config = MainConfiguration.Load(); pogoInstances = new List <PogoInstance>(config.Instances.Count); foreach (var instance in config.Instances) { instance.MainConfiguration = config; var walker = new Walker(instance.WalkingPoints); var startPosition = walker.GetNextPosition(); var session = Login.GetSession(instance.Username, instance.Password, instance.LoginProvider, startPosition.Latitude, startPosition.Longitude); var pogoInstance = new PogoInstance(instance, session, walker); pogoInstances.Add(pogoInstance); } }