private void Canvas_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; if (e.Key == Key.Return && gametimer.IsEnabled) { gametimer.Stop(); p1.RemovePokeball(1); ballcount.Text = p1.Pokeball_count.ToString(); checkresult(); } if (e.Key == Key.A && status == 3) { losetext.Visibility = Visibility.Hidden; poor.Visibility = Visibility.Hidden; good.Visibility = Visibility.Hidden; excellent.Visibility = Visibility.Hidden; if (p1.Pokeball_count > 0) { status = 1; game = new CaptureGame(pkm); objective.Visibility = Visibility.Visible; timercounter = 4; starttimer.Start(); } else { PokeballExhaust(); } } if (e.Key == Key.B && status == 3) { Program.status = 0; this.NavigationService.GoBack(); } }
private int status; //1: playing, 2: win, 3: lose public Capture(Player p, PokemonType x) { InitializeComponent(); EllipseX.SetCenter(objective, 384, 224); EllipseX.SetCenter(moving, 384, 224); p1 = p; pkm = x; game = new CaptureGame(x); status = 1; balltimer.Tick += ballTimer_Tick; balltimer.Interval = TimeSpan.FromSeconds(0.1); gametimer.Tick += gameTimer_Tick; gametimer.Interval = TimeSpan.FromSeconds(0.02); switch (pkm.Name) { case "Bulbasaur": Bulbasaur.Visibility = Visibility.Visible; break; case "Squirtle": Squirtle.Visibility = Visibility.Visible; break; case "Charmander": Charmander.Visibility = Visibility.Visible; break; case "Pikachu": Pikachu.Visibility = Visibility.Visible; break; case "Snorlax": Snorlax.Visibility = Visibility.Visible; break; case "Lapras": Lapras.Visibility = Visibility.Visible; break; } ballcount.Text = p1.Pokeball_count.ToString(); if (p1.Pokeball_count > 0) { CountdownTimer(); } else { PokeballExhaust(); } }