public void DisplayStats(GameStats gameStats) { Dispatcher.Invoke(() => { this.NavigationService.Navigate(new NetworkedGameOverPage(gameStats.HighScores, game.UserName)); }); UDPGameClient.StopListening(); }
private void Button_Click(object sender, RoutedEventArgs e) { this.NavigationService.Navigate(new NetworkedGamePage( UDPGameClient.JoinGame( userName, Window.GetWindow(this).ActualHeight, Window.GetWindow(this).ActualWidth ))); }
public NetworkedGamePage(NetworkedGame game) { UDPGameClient.SetCurrentGameReporter(this); this.game = game; UDPGameClient.StartListening(); game.GameUpdatedEvent += Render; InitializeComponent(); gameStarted = false; KeyUp += Window_KeyUp; this.KeyDown += Window_KeyDown; }
private void StartButton_Click(object sender, RoutedEventArgs e) { if (txtBxUser.Text != "" && txtBxUser.Text != null) { string uName = txtBxUser.Text; double w = App.Current.MainWindow.ActualWidth; double h = App.Current.MainWindow.ActualHeight; Task <NetworkedGame> myTask = Task.Run(() => UDPGameClient.JoinGame(uName, w, h)); myTask.ContinueWith((game) => StartGame(game.Result), TaskScheduler.FromCurrentSynchronizationContext()); } else { MessageBox.Show("You must enter a username!"); } }
private void GameWindow_Closed(object sender, EventArgs e) { if (gameStarted) { unstable.Close(); neutralize.Close(); deposit.Close(); orbGrab.Close(); powerup.Close(); collapse.Close(); ghost.Close(); boost.Close(); UDPGameClient.StopListening(); } App.Current.MainWindow.Show(); }
//This method sends the info for a key release internal void KeyReleased(char v) { UDPGameClient.SendKeyRelease(v); }
//This method sends the info for a keypress internal void KeyPressed(char v) { UDPGameClient.SendKeyPress(v); }