当前位置: 首页>>代码示例>>C#>>正文


C# Client.SetServer方法代码示例

本文整理汇总了C#中Client.SetServer方法的典型用法代码示例。如果您正苦于以下问题:C# Client.SetServer方法的具体用法?C# Client.SetServer怎么用?C# Client.SetServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.SetServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        private async void Execute()
        {
            var client = new Client(ClientSettings);

            try
            {

                await client.Login();

                await client.SetServer();
                var inventory = await client.GetInventory();
                var pokemons =
                    inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0).OrderByDescending(key => key.Cp);


                foreach (var pokemon in pokemons)
                {
                    ListViewItem lvi = new ListViewItem(pokemon.PokemonId.ToString());
                    listView1.Items.Add(lvi);
                    lvi.SubItems.Add(pokemon.Cp.ToString());
                }
            }
            catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); Execute(); }
            catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); Execute(); }
            catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); Execute(); }
            catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); Execute(); }
            catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); Execute(); }
            catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); Execute(); }
        }
开发者ID:CaptDreamer,项目名称:Pokemon-Go-Rocket-API,代码行数:30,代码来源:PokemonForm.cs

示例2: Execute

        public async void Execute()
        {
            Console.WriteLine($"Starting Execute on login server: {_clientSettings.AuthType}");

            var client = new Client(_clientSettings);

            while (true)
            {
                try
                {
                    if (_clientSettings.AuthType == AuthType.Ptc)
                        await client.DoPtcLogin(_clientSettings.PtcUsername, _clientSettings.PtcPassword);
                    else if (_clientSettings.AuthType == AuthType.Google)
                        await client.DoGoogleLogin();

                    await client.SetServer();
                    await RepeatAction(10, async () => await ExecuteFarmingPokestopsAndPokemons(client));
                    await TransferDuplicatePokemon();

                    /*
                * Example calls below
                *
                var profile = await client.GetProfile();
                var settings = await client.GetSettings();
                var mapObjects = await client.GetMapObjects();
                var inventory = await client.GetInventory();
                var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                */
                }
                catch(Exception ex)
                {
                    Console.WriteLine($"Exception: {ex}");
                }

                await Task.Delay(10000);
            }
        }
开发者ID:CppShane,项目名称:Pokemon-Go-Rocket-API,代码行数:37,代码来源:Logic.cs

示例3: Execute

        private static async void Execute()
        {
            //Boostrap - Replace with IoC Container
            var client = new Client(ClientSettings);
            IPokemonTransferer transferer = new PokemonTransferer(client);
            IEvolutionStrategy evolutionStrategy = new BasicEvolutionStrategy(client);
            ITransferStrategy transferStrategy = SelectTransferStrategy(client, transferer, ClientSettings);
            
            //Hook Up Events...
            evolutionStrategy.OnEvolve += EvolutionStrategy_OnEvolve;
            evolutionStrategy.OnEvolveFail += EvolutionStrategy_OnEvolveFail;

            transferStrategy.TransferSuccess += TransferStrategy_TransferSuccess;
            transferStrategy.TransferFailed += TransferStrategy_TransferFailed;
            transferStrategy.TransferIgnored += TransferStrategy_TransferIgnored;

            try
            {
                if (ClientSettings.AuthType == AuthType.Ptc)
                    await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                else if (ClientSettings.AuthType == AuthType.Google)
                    await client.DoGoogleLogin();

                await client.SetServer();


                //TODO: Clean this up
                await PrintBoostrap(client);
                await PrintBoostrap(client);


                //Step 1: Transfer any pokemon according to the users selected strategy
                await transferStrategy.Transfer();

                //Step 2: If we want to evolve, then apply to evolve strategy
                if (ClientSettings.EvolveAllGivenPokemons) await evolutionStrategy.Evolve();



                client.RecycleItems(client);

                await Task.Delay(5000);
                PrintLevel(client);
                await ExecuteFarmingPokestopsAndPokemons(client);
                ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["no_nearby_loc_found"]}");
                await Task.Delay(10000);
                Execute();
            }
            catch (TaskCanceledException tce) { ColoredConsoleWriteTimestamped(ConsoleColor.White, $"{Language.GetPhrases()["task_canceled_ex"]}"); Execute(); }
            catch (UriFormatException ufe) { ColoredConsoleWriteTimestamped(ConsoleColor.White, $"{Language.GetPhrases()["sys_uri_format_ex"]}"); Execute(); }
            catch (ArgumentOutOfRangeException aore) { ColoredConsoleWriteTimestamped(ConsoleColor.White, $"{Language.GetPhrases()["arg_out_of_range_ex"]}"); Execute(); }
            catch (ArgumentNullException ane) { ColoredConsoleWriteTimestamped(ConsoleColor.White, $"{Language.GetPhrases()["arg_null_ref"]}"); Execute(); }
            catch (NullReferenceException nre) { ColoredConsoleWriteTimestamped(ConsoleColor.White, $"{Language.GetPhrases()["null_ref"]}"); Execute(); }
            //await ExecuteCatchAllNearbyPokemons(client);
        }
开发者ID:XibalbaTM,项目名称:PokeBot2,代码行数:55,代码来源:Program.cs

示例4: ReloadPokemonList

        private async void ReloadPokemonList()
        {
            button1.Enabled = false;
            objectListView1.Enabled = false;

            client2 = new Client(ClientSettings);
            try
            {
                await client2.Login();
                await client2.SetServer();
                var inventory = await client2.GetInventory();
                var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0).OrderByDescending(key => key.Cp);
                families = inventory.InventoryDelta.InventoryItems
                   .Select(i => i.InventoryItemData?.PokemonFamily)
                   .Where(p => p != null && (int)p?.FamilyId > 0)
                   .OrderByDescending(p => (int)p.FamilyId);

                var prevTopItem = objectListView1.TopItemIndex;
                objectListView1.SetObjects(pokemons);
                objectListView1.TopItemIndex = prevTopItem;
            }
            catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); client2 = null; }

            button1.Enabled = true;
            objectListView1.Enabled = true;
        }
开发者ID:CaptDreamer,项目名称:Pokemon-Go-Rocket-API,代码行数:26,代码来源:MainForm.cs

示例5: Execute

        private async void Execute()
        {
            EnabledButton(false);
            textBox1.Text = "Reloading Pokemon list.";

            client = new Client(ClientSettings);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        await client.DoGoogleLogin();
                        break;
                }

                await client.SetServer();
                profile = await client.GetProfile();
                inventory = await client.GetInventory();
                pokemons =
                    inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);
                var families = inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.PokemonFamily)
                    .Where(p => p != null && (int)p?.FamilyId > 0)
                    .OrderByDescending(p => (int)p.FamilyId);

                var imageSize = 50;

                var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
                listView1.ShowItemToolTips = true;
                listView1.SmallImageList = imageList;

                var templates = await client.GetItemTemplates();
                var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonSettings = myPokemonSettings.ToList();

                var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonFamilies = myPokemonFamilies.ToArray();

                listView1.DoubleBuffered(true);
                listView1.View = View.Details;

                ColumnHeader columnheader;
                columnheader = new ColumnHeader();
                columnheader.Text = "Name";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "CP";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "IV A-D-S";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Candy";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Evolvable?";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Height";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Weight";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Attack";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "SpecialAttack";
                listView1.Columns.Add(columnheader);

                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;



                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                    listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", currIv, pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                    listViewItem.SubItems.Add(string.Format("{0}", currentCandy));
//.........这里部分代码省略.........
开发者ID:ZimboBoyd,项目名称:PokeBot3,代码行数:101,代码来源:Pokemons.cs

示例6: Execute

        private static async void Execute()
        {
            var client = new Client(ClientSettings);
            try
            {
                if (ClientSettings.AuthType == AuthType.Ptc)
                    await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                else if (ClientSettings.AuthType == AuthType.Google)
                    await client.DoGoogleLogin(ClientSettings.GoogleEmail, ClientSettings.GooglePassword);

                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"SetServer");
                await client.SetServer();
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"GetProfile");
                var profile = await client.GetProfile();
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"GetSettings");
                var settings = await client.GetSettings();
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"GetMapObjects");
                var mapObjects = await client.GetMapObjects();
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"GetInventory");
                var inventory = await client.GetInventory();
                var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"Transfer PK");
                await TransferDuplicatePokemon(client);



                ColoredConsoleWrite(ConsoleColor.Red, "Recycling Items");
                await Task.Delay(defaultDelay); ColoredConsoleWrite(ConsoleColor.White, $"client.RecycleItems(client)");
                await client.RecycleItems(client);


                ColoredConsoleWrite(ConsoleColor.Red, "ExecuteFarmingPokestopsAndPokemons");
                await ExecuteFarmingPokestopsAndPokemons(client);

                ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["no_nearby_loc_found"]}");
                await Task.Delay(2000);
                Execute();
            }
            catch (TaskCanceledException tce) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["task_canceled_ex"]}"); Execute(); }
            catch (UriFormatException ufe) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["sys_uri_format_ex"]}"); Execute(); }
            catch (ArgumentOutOfRangeException aore) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["arg_out_of_range_ex"]}"); Execute(); }
            catch (ArgumentNullException ane) { ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] {Language.GetPhrases()["arg_null_ref"]}"); Execute(); }
        }
开发者ID:ReiPlayGamesPL,项目名称:QuickPokeBot,代码行数:43,代码来源:Program.cs

示例7: Execute

        private async void Execute()
        {
            client = new Client(ClientSettings);
            this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club");
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        ColoredConsoleWrite(Color.Green, "Login Type: Google");
                        await client.DoGoogleLogin(ClientSettings.Email, ClientSettings.Password);

                        break;
                }
                
                await client.SetServer();
                var profile = await client.GetProfile();
                var settings = await client.GetSettings();
                connected = true;


                ConsoleLevelTitle(profile.Profile.Username, client);

                // Write the players ingame details
                WriteConnectLogs(profile);

                // I believe a switch is more efficient and easier to read.

                client.stopRecycle = false;
                stopPrintLevel = false;

                if (ClientSettings.Recycler)
                    recycle = client.RecycleItems(client);
                printLevel = PrintLevel(client);
                await EvolveAndTransfert(client);
                await ExecuteFarmingPokestopsAndPokemons(client);
                await UnbannedCheck();
            }
            catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); if (!Stopping) await Restart(client); }
            catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); if (!Stopping) await Restart(client); }
            catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); if (!Stopping) await Restart(client); }
            catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); if (!Stopping) await Restart(client); }
            catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); if (!Stopping) await Restart(client); }
            catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); if (!Stopping) await Restart(client); }
        }
开发者ID:Zayceur,项目名称:Pokemon-Go-Bot,代码行数:50,代码来源:MainForm.cs

示例8: Execute

        private async void Execute()
        {
            EnabledButton(false);
            textBox1.Text = "Reloading Pokemon list.";

            client = new Client(ClientSettings);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        await client.DoGoogleLogin();
                        break;
                }

                await client.SetServer();
                profile = await client.GetProfile();
                inventory = await client.GetInventory();
                pokemons =
                    inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);
                var families = inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.PokemonFamily)
                    .Where(p => p != null && (int)p?.FamilyId > 0)
                    .OrderByDescending(p => (int)p.FamilyId);

                var imageSize = 50;

                var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
                listView1.ShowItemToolTips = true;

                var templates = await client.GetItemTemplates();
                var myPokemonSettings =  templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonSettings = myPokemonSettings.ToList();

                var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonFamilies = myPokemonFamilies.ToArray();

                listView1.DoubleBuffered(true);
                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;


                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    //listViewItem.SubItems.Add();
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();

                    var pokemonId2 = pokemon.PokemonId;
                    var pokemonName = pokemon.Id;

                    listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
                    listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";

                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                    if (settings.EvolutionIds.Count > 0 && familyCandy.Candy > settings.CandyToEvolve)
                        listViewItem.Checked = true;

                    listView1.Items.Add(listViewItem);
                }
                Text = "Pokemon List | User: " + profile.Profile.Username + " | Pokemons: " + pokemons.Count() + "/" + profile.Profile.PokeStorage;
                EnabledButton(true);

                textBox1.Text = string.Empty;
            }
            catch (TaskCanceledException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (UriFormatException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentOutOfRangeException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentNullException e) {
                textBox1.Text = e.Message;
//.........这里部分代码省略.........
开发者ID:ReeViiS69,项目名称:PokemonGo-Bot,代码行数:101,代码来源:Pokemons.cs

示例9: Execute

        private async void Execute()
        {
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;

            client = new Client(ClientSettings);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        await client.DoGoogleLogin();
                        break;
                }
                //
                await client.SetServer();
                var inventory = await client.GetInventory();
                var pokemons =
                    inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);
                var families = inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.PokemonFamily)
                    .Where(p => p != null && (int)p?.FamilyId > 0)
                    .OrderByDescending(p => (int)p.FamilyId);




                var imageList = new ImageList { ImageSize = new Size(50, 50) };
                listView1.ShowItemToolTips = true;

                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;


                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    //listViewItem.SubItems.Add();
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();

                    var pokemonId2 = pokemon.PokemonId;
                    var pokemonName = pokemon.Id;

                    listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
                    listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";


                    this.listView1.Items.Add(listViewItem);


                }
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;

            }
            catch (TaskCanceledException) { Execute(); }
            catch (UriFormatException) { Execute(); }
            catch (ArgumentOutOfRangeException) { Execute(); }
            catch (ArgumentNullException) { Execute(); }
            catch (NullReferenceException) { Execute(); }
            catch (Exception ex) { Execute(); }
        }
开发者ID:Ryuya1995,项目名称:Pokemon-Go-Rocket-API,代码行数:83,代码来源:PokeUi.cs

示例10: Execute

        private async void Execute()
        {
            EnabledButton(false);

            client = new Client(ClientSettings);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        await client.DoGoogleLogin(ClientSettings.Email, ClientSettings.Password);
                        break;
                }
                await client.SetServer();
                var profile = await client.GetProfile();
                var inventory = await client.GetInventory();
                var pokemons =
                    inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderBy(p => p.PokemonId).ThenByDescending(p => Perfect(p));
                var families = inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.PokemonFamily)
                    .Where(p => p != null && (int)p?.FamilyId > 0)
                    .OrderByDescending(p => (int)p.FamilyId);



                var imageSize = ClientSettings.ImageSize;

                if ((imageSize > 96) || (imageSize < 1)) // no bigger than orig size and no smaller than 1x1
                    imageSize = 50;

                var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
                //var imageList = new ImageList { ImageSize = new Size(96, 96) };
                listView1.ShowItemToolTips = true;

                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;


                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    //listViewItem.SubItems.Add();
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();

                    var pokemonId2 = pokemon.PokemonId;
                    var pokemonName = pokemon.Id;

                    listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
                    listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";


                    this.listView1.Items.Add(listViewItem);

                }
                this.Text = "PokeUi " + pokemons.Count<PokemonData>() + "/" + profile.Profile.PokeStorage;
                EnabledButton(true);


            }
            catch (TaskCanceledException) { Execute(); }
            catch (UriFormatException) { Execute(); }
            catch (ArgumentOutOfRangeException) { Execute(); }
            catch (ArgumentNullException) { Execute(); }
            catch (NullReferenceException) { Execute(); }
            catch (Exception ex) { Execute(); }
        }
开发者ID:Zayceur,项目名称:Pokemon-Go-Bot,代码行数:85,代码来源:PokeUi.cs

示例11: loginPtc

        private async Task loginPtc(string username, string password)
        {
            try
            {
                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType = AuthType.Ptc.ToString();
                UserSettings.Default.PtcUsername = username;
                UserSettings.Default.PtcPassword = password;
                this.settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with PTC Credentials...");
                Client client = new Client(this.settings);
                await client.DoPtcLogin(this.settings.PtcUsername, this.settings.PtcPassword);
                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");
                this.client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                this.inventory = new Inventory(client);
                this.profile = await client.GetProfile();
                enableButtons();
            }         
            catch
            {
                Logger.Write("Unable to Connect using the PTC Credentials.");
                MessageBox.Show("Unable to Authenticate with Login Server.", "Login Problem");
                Application.Exit();
            }
        }
开发者ID:yuugiou40,项目名称:PokemonGo-Bot-SimpleGUI,代码行数:33,代码来源:MainForm.cs

示例12: Execute

        private async void Execute()
        {
            client = new Client(ClientSettings);
            this.locationManager = new LocationManager(client, ClientSettings.TravelSpeed);
            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        ColoredConsoleWrite(Color.Green, "Login Type: Pokemon Trainers Club");
                        break;
                    case AuthType.Google:
                        ColoredConsoleWrite(Color.Green, "Login Type: Google");
                        break;
                }

                await client.Login();
                await client.SetServer();
                var profile = await client.GetProfile();
                var settings = await client.GetSettings();
                var mapObjects = await client.GetMapObjects();
                var inventory = await client.GetInventory();
                var pokemons =
                    inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0);

                updateUserStatusBar(client);

                // Write the players ingame details
                ColoredConsoleWrite(Color.Yellow, "----------------------------");
                /*// dont actually want to display info but keeping here incase people want to \O_O/
                 * if (ClientSettings.AuthType == AuthType.Ptc)
                {
                    ColoredConsoleWrite(Color.Cyan, "Account: " + ClientSettings.PtcUsername);
                    ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.PtcPassword + "\n");
                }
                else
                {
                    ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.Email);
                    ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.Password + "\n");
                }*/
                string lat2 = System.Convert.ToString(ClientSettings.DefaultLatitude);
                string longit2 = System.Convert.ToString(ClientSettings.DefaultLongitude);
                ColoredConsoleWrite(Color.DarkGray, "Name: " + profile.Profile.Username);
                ColoredConsoleWrite(Color.DarkGray, "Team: " + profile.Profile.Team);
                if (profile.Profile.Currency.ToArray()[0].Amount > 0) // If player has any pokecoins it will show how many they have.
                    ColoredConsoleWrite(Color.DarkGray, "Pokecoins: " + profile.Profile.Currency.ToArray()[0].Amount);
                ColoredConsoleWrite(Color.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount + "\n");
                ColoredConsoleWrite(Color.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude);
                ColoredConsoleWrite(Color.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude);
                try
                {
                    ColoredConsoleWrite(Color.DarkGray, "Country: " + CallAPI("country", lat2.Replace(',', '.'), longit2.Replace(',', '.')));
                    ColoredConsoleWrite(Color.DarkGray, "Area: " + CallAPI("place", lat2.Replace(',', '.'), longit2.Replace(',', '.')));
                }
                catch (Exception)
                {
                    ColoredConsoleWrite(Color.DarkGray, "Unable to get Country/Place");
                }


                ColoredConsoleWrite(Color.Yellow, "----------------------------");

                // I believe a switch is more efficient and easier to read.
                switch (ClientSettings.TransferType)
                {
                    case "Leave Strongest":
                        await TransferAllButStrongestUnwantedPokemon(client);
                        break;
                    case "All":
                        await TransferAllGivenPokemons(client, pokemons);
                        break;
                    case "CP Duplicate":
                        await TransferDuplicatePokemon(client);
                        break;
                    case "IV Duplicate":
                        await TransferDuplicateIVPokemon(client);
                        break;
                    case "CP/IV Duplicate":
                        await TransferDuplicateCPIVPokemon(client);
                        break;
                    case "CP":
                        await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
                        break;
                    case "IV":
                        await TransferAllGivenPokemons(client, pokemons, ClientSettings.TransferIVThreshold);
                        break;
                    default:
                        ColoredConsoleWrite(Color.DarkGray, "Transfering pokemon disabled");
                        break;
                }


                if (ClientSettings.EvolveAllGivenPokemons)
                    await EvolveAllGivenPokemons(client, pokemons);
                if (ClientSettings.Recycler)
                    client.RecycleItems(client);

                await Task.Delay(5000);
                PrintLevel(client);
//.........这里部分代码省略.........
开发者ID:CaptDreamer,项目名称:Pokemon-Go-Rocket-API,代码行数:101,代码来源:MainForm.cs

示例13: loginGoogle

        private async Task loginGoogle()
        {
            try
            {
                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType = AuthType.Google.ToString();
                this.settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with Google Token...");
                Client client = new Client(this.settings);
                await client.DoGoogleLogin();
                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");
                this.client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                this.inventory = new Inventory(client);
                this.profile = await client.GetProfile();
                enableButtons();
            }
            catch
            {
                Logger.Write("Unable to Connect using the Google Token.");
                MessageBox.Show("Unable to Authenticate with Login Server.", "Login Problem");
                Application.Exit();
            }
        }
开发者ID:yuugiou40,项目名称:PokemonGo-Bot-SimpleGUI,代码行数:31,代码来源:MainForm.cs

示例14: LoginPtc

        private async Task LoginPtc(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Ptc;
                _username = username;
                _password = password;

                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType = AuthType.Ptc.ToString();
                UserSettings.Default.PtcUsername = username;
                UserSettings.Default.PtcPassword = password;
                _settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with PTC Credentials...");
                Client client = new Client(_settings);
                await client.DoPtcLogin(_settings.PtcUsername, _settings.PtcPassword);
                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");                
                _client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                _inventory = new Inventory(client);
                _profile = await client.GetProfile();
                EnableButtons();
                _loginSuccess = true;
            }         
            catch(Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("PTCLoginError", "Unable to Login with PTC", ex);

                Logger.Write("Unable to Connect using the PTC Credentials.");
                MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
                Application.Exit();
            }
        }
开发者ID:yuyutak,项目名称:PokemonGo-Bot-SimpleGUI,代码行数:42,代码来源:MainForm.cs

示例15: LoginGoogle

        private async Task LoginGoogle(string username, string password)
        {
            try
            {
                // Login Method
                _loginMethod = AuthType.Google;
                _username = username;
                _password = password;

                // Creating the Settings
                Logger.Write("Adjusting the Settings.");
                UserSettings.Default.AuthType = AuthType.Google.ToString();
                _settings = new Settings();

                // Begin Login
                Logger.Write("Trying to Login with Google Token...");
                Client client = new Client(_settings);
                client.DoGoogleLogin(username, password);
                await client.SetServer();

                // Server Ready
                Logger.Write("Connected! Server is Ready.");
                _client = client;

                Logger.Write("Attempting to Retrieve Inventory and Player Profile...");
                _inventory = new Inventory(client);
                _profile = await client.GetProfile();
                EnableButtons();
                _loginSuccess = true;
            }
            catch (GoogleException ex)
            {
                if(ex.Message.Contains("NeedsBrowser"))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("It seems you have Google 2 Factor Authentication enabled.");
                    sb.AppendLine("In order to enable this bot to access your Google Account you need to create an App Password and use that one instead of your Google Password.");
                    sb.AppendLine();
                    sb.AppendLine("Please go to: https://security.google.com/settings/security/apppasswords");                    
                    sb.AppendLine("In 'Select App' select 'Other' and 'on my' select 'Windows Computer'.");
                    sb.AppendLine();
                    sb.AppendLine("This will generate a random password use that password login to the bot.");                    
                    MessageBox.Show(sb.ToString(), "Google 2 Factor Authentication");
                    Application.Exit();
                }

                if(ex.Message.Contains("BadAuth"))
                {
                    MessageBox.Show("Your Google Credentials are incorrect.", "Google Login");
                    Application.Exit();
                }
            }
            catch(Exception ex)
            {
                // Error Logging
                ErrorReportCreator.Create("GoogleLoginError", "Unable to Login with Google", ex);

                Logger.Write("Unable to Connect using the Google Token.");
                MessageBox.Show(@"Unable to Authenticate with Login Server.", @"Login Problem");
                Application.Exit();
            }
        }
开发者ID:yuyutak,项目名称:PokemonGo-Bot-SimpleGUI,代码行数:62,代码来源:MainForm.cs


注:本文中的Client.SetServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。