Esempio n. 1
0
 private static void OnGameOver(PongGame game)
 {
     lock (_syncRoot)
     {
         _games.Remove(game);
     }
 }
Esempio n. 2
0
 private static void OnGameOver(PongGame game)
 {
     lock (_syncRoot)
     {
         _games.Remove(game);
     }
 }
Esempio n. 3
0
 public void SetGame(PongGame game)
 {
     if (_game != null)
     {
         throw new InvalidOperationException();
     }
     _game = game;
 }
Esempio n. 4
0
 /// <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);
     }
 }
Esempio n. 5
0
 /// <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;
 }