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