private static void OnGameOver(PongGame game)
 {
     lock (_syncRoot)
     {
         _games.Remove(game);
     }
 }
 private static void OnGameOver(PongGame game)
 {
     lock (_syncRoot)
     {
         _games.Remove(game);
     }
 }
Exemple #3
0
 public void SetGame(PongGame game)
 {
     if (_game != null)
     {
         throw new InvalidOperationException();
     }
     _game = game;
 }
 /// <summary>
 /// Joins new player to existing game or creates new one
 /// </summary>
 /// <param name="player"></param>
 public static void JoinPlayer(PongPlayer player)
 {
     lock (_syncRoot)
     {
         var game = _games.Where(g => g.State == GameState.WaitingForPlayer).FirstOrDefault();
         if (game == null)
         {
             game = new PongGame();
             _games.Add(game);
             game.GameOver += OnGameOver;
         }
         game.JoinPlayer(player);
     }
 }
 /// <summary>
 /// Joins new player to existing game or creates new one 
 /// </summary>
 /// <param name="player"></param>
 public static void JoinPlayer(PongPlayer player)
 {
     lock (_syncRoot)
     {
         var game = _games.Where(g => g.State == GameState.WaitingForPlayer).FirstOrDefault();
         if (game == null)
         {
             game = new PongGame();
             _games.Add(game);
             game.GameOver += OnGameOver;
         }
         game.JoinPlayer(player);
     }
 }
 public void SetGame(PongGame game)
 {
     if (_game != null)
         throw new InvalidOperationException();
     _game = game;
 }