private async void EndCatchGame(int catchgameStatus) { Pokemon pmToCatch = catchgame.Poke_catching; if (catchgameStatus == 1) { CatchMessageTB.Text = String.Format("You caught {0}! Going back to map...", pmToCatch.Name); player.Add_poke(pmToCatch); } else { CatchMessageTB.Text = String.Format("{0} fleed! Going back to map...", pmToCatch.Name); } dispatcherTimer.Tick -= UpdatePerTick; dispatcherTimer.Stop(); catchgame = null; catchGameInputTBx.Text = ""; WordToTypeTB.Text = ""; CatchGameInstrTB.Visibility = System.Windows.Visibility.Hidden; // wait 2.5 seconds before going back to map await Task.Delay(2500); tabControl.SelectedIndex = 0; UpdateLayout(); MapPanel.Focus(); WorldMap.despawn(WorldMap.getable()[0], WorldMap.getable()[1]); DrawMap(); }
private void StartNewCatchGame(Pokemon pmToCatch, bool usedGreatBall, bool usedRazzberry) { catchgame = new catch_poke_game(1, pmToCatch, usedGreatBall, usedRazzberry); tabControl.SelectedIndex = 3; UpdateLayout(); WordToTypeTB.Text = catchgame.Word_now; TimerTB.Visibility = Visibility.Visible; TimerTB.Text = "Time: " + ((int)catchgame.TimeRemained).ToString() + "s"; ScoreTB.Visibility = Visibility.Visible; ScoreTB.Text = "Score: " + catchgame.Score.ToString(); catchGameInputTBx.Text = ""; catchGameInputTBx.Focus(); // timer start dispatcherTimer.Tick += UpdatePerTick; dispatcherTimer.Interval = TimeSpan.FromSeconds(1); dispatcherTimer.Start(); }