Exemple #1
0
 public void ListenForAllPlayersReady(IEnumerable <string> playersId, Action <string> onNewPlayerReady,
                                      Action onAllPlayersReady,
                                      Action <AggregateException> fallback)
 {
     readyPlayers  = playersId.ToDictionary(playerId => playerId, playerId => false);
     readyListener = DatabaseAPI.ListenForChildAdded($"games/{currentGameInfo.gameId}/ready/", args =>
     {
         readyPlayers[args.Snapshot.Key] = true;
         onNewPlayerReady(args.Snapshot.Key);
         if (!readyPlayers.All(readyPlayer => readyPlayer.Value))
         {
             return;
         }
         StopListeningForAllPlayersReady();
         onAllPlayersReady();
     }, fallback);
 }