Example #1
0
        private void GoBattleButton_Click(object sender, RoutedEventArgs e)
        {
            if (ChooseBattlePMListBox.SelectedIndex == -1)
            {
                return;
            }
            Pokemon pmSelected = player.All_poke[ChooseBattlePMListBox.SelectedIndex];

            tabControl.SelectedIndex = 2;
            s1button.Visibility      = System.Windows.Visibility.Hidden;
            s2button.Visibility      = System.Windows.Visibility.Hidden;
            battlegame = new Gym_battle(pmSelected, mgym.Bat_list_front, mgym);
            GymBattleLeadIn(battlegame);
        }
Example #2
0
        private async void GymBattleLeadIn(Gym_battle battle)
        {
            Pokemon guestPM = battle.GuestPM;
            Pokemon hostPM  = battle.HostPM;

            BattleGuestHPTB.Text     = "HP: " + guestPM.NowHP.ToString() + "/" + guestPM.maxHP.ToString();
            GuestPmPanel.DataContext = guestPM;
            AppendBattleLog("You challenged the Gym Leader!");
            HostPmPanel.Visibility = Visibility.Hidden;
            await Task.Delay(2000);

            HostPmPanel.DataContext = hostPM;
            HostPmPanel.Visibility  = Visibility.Visible;
            BattleHostHPTB.Text     = "HP: " + hostPM.NowHP.ToString() + "/" + hostPM.maxHP.ToString();
            AppendBattleLog("Gym Leader sent out " + battlegame.HostPM.Name + "!");
            await Task.Delay(2000);

            s1button.Visibility = System.Windows.Visibility.Visible;
            s2button.Visibility = System.Windows.Visibility.Visible;
            s1button.Content    = datalist.Skill_Name(battle.GuestPM.Skills[0]);
            s2button.Content    = datalist.Skill_Name(battle.GuestPM.Skills[1]);
            AppendBattleLog("What do you do?\n");
        }
Example #3
0
        private async void DrawRoundResult()
        {
            string guestPMName = battlegame.GuestPM.Name;
            string hostPMName  = battlegame.HostPM.Name;

            // Guest PM use skill
            AppendBattleLog(String.Format("{0}'s {1} uses {2}.",
                                          player.Name, guestPMName, battlegame.GuestLastSkill));
            await Task.Delay(500);

            // Damage to Host PM
            BattleHostHPTB.Text = "HP: " + battlegame.HostPM.NowHP.ToString() +
                                  "/" + battlegame.HostPM.maxHP.ToString();
            if (battlegame.DamageToHost != 0)
            {
                AppendBattleLog(String.Format("Gym Leader's {0} receives {1} damages!",
                                              hostPMName, battlegame.DamageToHost));
            }
            else
            {
                AppendBattleLog(String.Format("Gym Leader's {0} evaded!",
                                              hostPMName));
            }
            await Task.Delay(1000);

            // If Host PM faints, guest wins
            if (battlegame.ResultStatus == Gym_battle.Result.HostFaint)
            {
                AppendBattleLog(String.Format("Gym Leader's {0} faints!",
                                              hostPMName));
                AppendBattleLog("\nYou win!");
                await Task.Delay(1000);
            }
            // If Host PM not faints
            else
            {
                // Host PM use skill
                AppendBattleLog(String.Format("Gym Leader's {0} uses {1}.",
                                              hostPMName, battlegame.HostLastSkill));
                await Task.Delay(500);

                // Damage to Guest PM
                BattleGuestHPTB.Text = "HP: " + battlegame.GuestPM.NowHP.ToString() +
                                       "/" + battlegame.GuestPM.maxHP.ToString();
                if (battlegame.DamageToGuest != 0)
                {
                    AppendBattleLog(String.Format("{0}'s {1} receives {2} damages!",
                                                  player.Name, guestPMName, battlegame.DamageToGuest));
                }
                else
                {
                    AppendBattleLog(String.Format("{0}'s {1} evaded!",
                                                  player.Name, guestPMName));
                }
                await Task.Delay(1000);

                // If Guest PM faints, guest loses
                if (battlegame.ResultStatus == Gym_battle.Result.GuestFaint)
                {
                    AppendBattleLog(String.Format("{0}'s {1} faints!",
                                                  player.Name, guestPMName));
                    AppendBattleLog("\nYou loses...");
                    await Task.Delay(1000);
                }
            }

            // After all moves completed, next round or end game
            if (battlegame.ResultStatus == Gym_battle.Result.NoFaint)
            {
                AppendBattleLog("\nWhat do you do?\n");
                s1button.Visibility = System.Windows.Visibility.Visible;
                s2button.Visibility = System.Windows.Visibility.Visible;
            }
            else if (battlegame.ResultStatus != Gym_battle.Result.NoFaint)
            {
                AppendBattleLog("\nGoing back to map...");
                // wait 2.5 seconds before going back to map
                await Task.Delay(2500);

                battlegame               = null;
                BattleInfoTBx.Text       = "";
                tabControl.SelectedIndex = 0;
                UpdateLayout();
                MapPanel.Focus();
            }
        }