private async void btnSnipe_Click(object sender, EventArgs e)
        {
            try
            {
                // Clear Box
                textResults.Clear();

                // Disable Stuff
                boxCoordinates.Enabled = false;
                btnSnipe.Enabled = false;

                // Verify the Coordinates are valid
                string delim = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
                string[] coordinates = boxCoordinates.Text.Trim().Replace(',', '/').Replace('.', char.Parse(delim)).Split('/');
                double lat = double.Parse(coordinates[0]);
                double lng = double.Parse(coordinates[1]);
                textResults.AppendText("Coordinates are valid." + Environment.NewLine);

                // Persist Coordinates
                _lat = lat;
                _lng = lng;

                // Being by moving to the location
                await _client.UpdatePlayerLocation(lat, lng, _client.Settings.DefaultAltitude);
                textResults.AppendText("Teleported to Snipe Location." + Environment.NewLine);

                // Remove the Ban
                textResults.AppendText("Will try to remove soft ban now, this will take less than 1 minute." + Environment.NewLine);
                if (!await ForceUnban())
                {
                    textResults.AppendText("Unable to remove soft ban, most likely the Pokemon(s) will run away." + Environment.NewLine);
                } else
                {
                    textResults.AppendText("Removed soft ban with success." + Environment.NewLine);
                }

                // Maybe walk to the location instead of teleporting...
                var distanceToPokemon = Helpers.LocationUtils.CalculateDistanceInMeters(new GeoCoordinate(_client.CurrentLat, _client.CurrentLng), new GeoCoordinate(lat, lng));
                textResults.AppendText($"Walking from Pokestop to the Pokemon, will take {distanceToPokemon / (60 / 3.6):0.0} seconds..." + Environment.NewLine);
                Navigation.HumanWalking walker = new Navigation.HumanWalking(_client);
                await walker.Walk(new GeoCoordinate(lat, lng), 60);
                textResults.AppendText("Arrived to Pokemon Location, will try to catch it now." + Environment.NewLine);

                // Catch Pokemons in the Area
                await ExecuteCatchAllNearbyPokemons();

                // Finish
                textResults.AppendText("Sniping Complete." + Environment.NewLine);

                // Enable Stuff
                boxCoordinates.Enabled = true;
                btnSnipe.Enabled = true;
            }
            catch(Exception ex)
            {
                textResults.Text = ex.ToString();
                MessageBox.Show("Error during Pokemon Snipe, see details in results box.");
            }
        }
        private async void btnSnipe_Click(object sender, EventArgs e)
        {
            try
            {
                // Clear Box
                textResults.Clear();

                // Disable Stuff
                boxCoordinates.Enabled = false;
                btnSnipe.Enabled       = false;

                // Verify the Coordinates are valid
                string[] coordinates = boxCoordinates.Text.Trim().Split(',');
                double   lat         = double.Parse(coordinates[0]);
                double   lng         = double.Parse(coordinates[1]);
                textResults.AppendText("Coordinates are valid." + Environment.NewLine);

                // Persist Coordinates
                _lat = lat;
                _lng = lng;

                // Being by moving to the location
                await _client.UpdatePlayerLocation(lat, lng, _client.Settings.DefaultAltitude);

                textResults.AppendText("Teleported to Snipe Location." + Environment.NewLine);

                // Remove the Ban
                textResults.AppendText("Will try to remove soft ban now, this will take less than 1 minute." + Environment.NewLine);
                if (!await ForceUnban())
                {
                    textResults.AppendText("Unable to remove soft ban, most likely the Pokemon(s) will run away." + Environment.NewLine);
                }
                else
                {
                    textResults.AppendText("Removed soft ban with success." + Environment.NewLine);
                }

                // Maybe walk to the location instead of teleporting...
                var distanceToPokemon = Helpers.LocationUtils.CalculateDistanceInMeters(new GeoCoordinate(_client.CurrentLat, _client.CurrentLng), new GeoCoordinate(lat, lng));
                textResults.AppendText($"Walking from Pokestop to the Pokemon, will take {distanceToPokemon / (60 / 3.6):0.0} seconds..." + Environment.NewLine);
                Navigation.HumanWalking walker = new Navigation.HumanWalking(_client);
                await walker.Walk(new GeoCoordinate(lat, lng), 60);

                textResults.AppendText("Arrived to Pokemon Location, will try to catch it now." + Environment.NewLine);

                // Catch Pokemons in the Area
                await ExecuteCatchAllNearbyPokemons();

                // Finish
                textResults.AppendText("Sniping Complete." + Environment.NewLine);

                // Enable Stuff
                boxCoordinates.Enabled = true;
                btnSnipe.Enabled       = true;
            }
            catch (Exception ex)
            {
                textResults.Text = ex.ToString();
                MessageBox.Show("Error during Pokemon Snipe, see details in results box.");
            }
        }
예제 #3
0
        private async Task ExecuteFarmingPokestopsAndPokemons()
        {
            var mapObjects = await _client.GetMapObjects();

            var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());

            var fortDatas = pokeStops as IList<FortData> ?? pokeStops.ToList();
            _pokestopsCount = fortDatas.Count<FortData>();
            int count = 1;

            foreach (var pokeStop in fortDatas)
            {
                // Use Teleporting if No Human Walking Enabled
                if (!GUISettings.Default.humanWalkingEnabled)
                {
                    var update = await _client.UpdatePlayerLocation(pokeStop.Latitude, pokeStop.Longitude, _settings.DefaultAltitude); // Redundant?
                    UpdateMap(pokeStop.Latitude, pokeStop.Longitude);
                } else
                {
                    HumanWalking human = new HumanWalking(_client);
                    GeoCoordinate targetLocation = new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude);
                    human.assignMapToUpdate(MainMap);
                    await human.Walk(targetLocation, GUISettings.Default.humanWalkingSpeed, ExecuteCatchAllNearbyPokemons);
                }               

                var fortInfo = await _client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                boxPokestopName.Text = fortInfo.Name;
                boxPokestopInit.Text = count.ToString();
                boxPokestopCount.Text = _pokestopsCount.ToString();
                count++;                               

                var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                Logger.Write($"Loot -> Gems: { fortSearch.GemsAwarded}, Eggs: {fortSearch.PokemonDataEgg} Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}");
                Logger.Write("Gained " + fortSearch.ExperienceAwarded + " XP.");

                // Experience Counter
                _totalExperience += fortSearch.ExperienceAwarded;

                await GetCurrentPlayerInformation();
                Logger.Write("Attempting to Capture Nearby Pokemons.");

                try
                {
                    await ExecuteCatchAllNearbyPokemons();
                }
                catch(Exception ex)
                {
                    Logger.Write("Error while trying to catch nearby Pokemon(s).");
                    ErrorReportCreator.Create("CatchingNearbyPokemonError", "Unable to Catch Nearby Pokemon(s).", ex);
                }

                if (!_isFarmingActive)
                {
                    Logger.Write("Stopping Farming Pokestops.");
                    return;
                }                    

                Logger.Write("Waiting before moving to the next Pokestop.");
                await Task.Delay(GUISettings.Default.pokestopDelay * 1000);
            }
        }