Пример #1
0
        private async Task LoadPokemon(int num, int trainerNum)
        {
            //Returns pokemon from API
            var pokemon = await PokemonProcessor.LoadPokemon(num);

            //Displays pokemon information
            try
            {
                if (trainerNum == 1)
                {
                    //Capitalize the first letter in the name
                    lblPokemon1.Text = pokemon.name.First().ToString().ToUpper() + pokemon.name.Substring(1);
                    pictureBox1.Load(pokemon.sprites.back_default);
                }
                else
                {
                    lblPokemon2.Text = pokemon.name.First().ToString().ToUpper() + pokemon.name.Substring(1);
                    pictureBox2.Load(pokemon.sprites.front_default);
                }
            }
            catch
            {
                MessageBox.Show("There was an error when retrieving image");
            }
            //Adds pokemon to list
            BattlePokemon.Add(pokemon);
        }
Пример #2
0
        private async Task LoadType(string type)
        {
            try
            {
                var damageRelation = await PokemonProcessor.LoadType(type);

                PokemonDamage1.Add(damageRelation);
            }
            catch
            {
                MessageBox.Show("There was an error when loading pokemon type");
            }
        }
Пример #3
0
 private async Task LoadPokemonType(int num)
 {
     foreach (var t in BattlePokemon[num].types)
     {
         if (num == 0)
         {
             PokemonDamage1.Add(await PokemonProcessor.LoadType(t.type.name));
         }
         else
         {
             PokemonDamage2.Add(await PokemonProcessor.LoadType(t.type.name));
         }
     }
 }