public void Show(Pokemon p)
 {
     lblName.Content = p.Name;
     img.Source = p.Image;
     listView.ItemsSource = typeof(StatsClass).GetProperties()
         .Where(pr => !pr.Name.EndsWith("Hp"))
         .Select(pr => new { Name = pr.Name, Value = pr.GetValue(p.InBattle.Stats) });
     moves.DataContext = p.Moves;
     Visibility = Visibility.Visible;
 }
Ejemplo n.º 2
0
 private async void MainLoop()
 {
     while (true)
     {
         switch (await server.ReadType())
         {
             case MessageType.BeginTurn:
                 gridFooter.IsEnabled = true;
                 break;
             case MessageType.ChangeOpponent:
                 opponent = await server.ReadPokemon();
                 pokev2.DataContext = opponent;
                 textBlock.Text += $"The opponent sent {opponent.Name}.\n";
                 break;
             case MessageType.InBattleOpponent:
                 opponent.InBattle = await server.ReadInBattle();
                 break;
             case MessageType.InBattleUser:
                 ActivePokemon.InBattle = await server.ReadInBattle();
                 break;
             case MessageType.OpponentFainted:
                 textBlock.Text += opponent.Name + " opponent fainted.\n";
                 popAskChange.Visibility = Visibility.Visible;
                 break;
             case MessageType.PokeTeam: // should happen only once
                 pokeTeam = await server.ReadPokeTeam();
                 pokePicker.PokeTeam = pokeTeam;
                 ActiveIndex = 0;
                 break;
             case MessageType.Text:
                 textBlock.Text += await server.ReadText();
                 break;
             case MessageType.UserFainted:
                 textBlock.Text += ActivePokemon.Name + " fainted. Choose another pokemon.\n";
                 pokePicker.Show(activeIndex, false);
                 break;
         }
     }
 }
 public PickedPokemonArgs(Pokemon poke, int idx)
 {
     PickedPokemon = poke;
     PickedIndex = idx;
 }