예제 #1
0
 public void DisplayStats(GameStats gameStats)
 {
     Dispatcher.Invoke(() => {
         this.NavigationService.Navigate(new NetworkedGameOverPage(gameStats.HighScores, game.UserName));
     });
     UDPGameClient.StopListening();
 }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     this.NavigationService.Navigate(new NetworkedGamePage(
                                         UDPGameClient.JoinGame(
                                             userName,
                                             Window.GetWindow(this).ActualHeight,
                                             Window.GetWindow(this).ActualWidth
                                             )));
 }
예제 #3
0
        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!");
            }
        }
예제 #5
0
 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();
 }
예제 #6
0
 //This method sends the info for a key release
 internal void KeyReleased(char v)
 {
     UDPGameClient.SendKeyRelease(v);
 }
예제 #7
0
 //This method sends the info for a keypress
 internal void KeyPressed(char v)
 {
     UDPGameClient.SendKeyPress(v);
 }