示例#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);
 }