Ejemplo n.º 1
0
 public void DisplayStats(GameStats gameStats)
 {
     Dispatcher.Invoke(() => {
         this.NavigationService.Navigate(new NetworkedGameOverPage(gameStats.HighScores, game.UserName));
     });
     UDPGameClient.StopListening();
 }
Ejemplo n.º 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
                                             )));
 }
Ejemplo n.º 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!");
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 6
0
 //This method sends the info for a key release
 internal void KeyReleased(char v)
 {
     UDPGameClient.SendKeyRelease(v);
 }
Ejemplo n.º 7
0
 //This method sends the info for a keypress
 internal void KeyPressed(char v)
 {
     UDPGameClient.SendKeyPress(v);
 }