Exemplo n.º 1
0
 public void LoadGameInfo(Action callback = null)
 {
     AppsService.Instance.GetGameDashboard(this._gameHeader.Game.id, (Action <BackendResult <GameDashboardResponse, ResultCode> >)(res =>
     {
         if (callback != null)
         {
             Execute.ExecuteOnUIThread(callback);
         }
         GameDashboardResponse resultData = res.ResultData;
         int leaderboardType = this._gameHeader.Game.leaderboard_type;
         if (leaderboardType > 0)
         {
             List <GameLeaderboardItem> items        = resultData.leaderboard.items;
             List <GameLeaderboardItemHeader> source = new List <GameLeaderboardItemHeader>();
             for (int index = 0; index < items.Count; ++index)
             {
                 GameLeaderboardItem leaderboardItem = items[index];
                 User user = resultData.leaderboard.profiles.FirstOrDefault <User>((Func <User, bool>)(u => u.id == leaderboardItem.user_id));
                 GameLeaderboardItemHeader leaderboardItemHeader = new GameLeaderboardItemHeader(leaderboardItem, user, leaderboardType, index + 1);
                 source.Add(leaderboardItemHeader);
             }
             this.LeaderboardType = leaderboardType;
             this.GameLeaderboard = new List <GameLeaderboardItemHeader>(source.Take <GameLeaderboardItemHeader>(10));
         }
         else if (resultData.activity != null && !resultData.activity.items.IsNullOrEmpty())
         {
             List <VKClient.Audio.Base.DataObjects.GameActivity> items = resultData.activity.items;
             List <GameActivityHeader> gameActivityHeaderList          = new List <GameActivityHeader>();
             foreach (VKClient.Audio.Base.DataObjects.GameActivity gameActivity in items)
             {
                 VKClient.Audio.Base.DataObjects.GameActivity activity = gameActivity;
                 Game game = resultData.activity.apps.FirstOrDefault <Game>((Func <Game, bool>)(app => app.id == activity.app_id));
                 User user = resultData.activity.profiles.FirstOrDefault <User>((Func <User, bool>)(u => u.id == activity.user_id));
                 GameActivityHeader gameActivityHeader = new GameActivityHeader(activity, game, user);
                 gameActivityHeaderList.Add(gameActivityHeader);
             }
             this.GameActivity = new List <GameActivityHeader>((IEnumerable <GameActivityHeader>)gameActivityHeaderList);
         }
         if (resultData.requests == null || resultData.requests.items.IsNullOrEmpty())
         {
             return;
         }
         List <GameRequest> items1 = resultData.requests.items;
         List <GameRequestHeader> gameRequestHeaderList = new List <GameRequestHeader>();
         foreach (GameRequest gameRequest in items1.Where <GameRequest>((Func <GameRequest, bool>)(request => request.type != "invite")))
         {
             GameRequest request = gameRequest;
             Game game           = resultData.requests.apps.FirstOrDefault <Game>((Func <Game, bool>)(app => app.id == request.app_id));
             User user           = resultData.requests.profiles.FirstOrDefault <User>((Func <User, bool>)(u => u.id == request.from_id));
             GameRequestHeader gameRequestHeader = new GameRequestHeader(request, game, user);
             gameRequestHeaderList.Add(gameRequestHeader);
         }
         this.GameRequests = new List <GameRequestHeader>((IEnumerable <GameRequestHeader>)gameRequestHeaderList);
     }));
 }
Exemplo n.º 2
0
 public void LoadGameInfo(Action callback = null)
 {
     AppsService.Instance.GetGameDashboard(this._gameHeader.Game.id, (Action <BackendResult <GameDashboardResponse, ResultCode> >)(res =>
     {
         if (callback != null)
         {
             Execute.ExecuteOnUIThread(callback);
         }
         GameDashboardResponse resultData = res.ResultData;
         int leaderboardType = this._gameHeader.Game.leaderboard_type;
         if (leaderboardType > 0)
         {
             List <GameLeaderboardItem> items = resultData.leaderboard.items;
             List <GameLeaderboardItemHeader> leaderboardItemHeaderList = new List <GameLeaderboardItemHeader>();
             for (int index = 0; index < items.Count; ++index)
             {
                 GameLeaderboardItem leaderboardItem = items[index];
                 User user = (User)Enumerable.FirstOrDefault <User>(resultData.leaderboard.profiles, (Func <User, bool>)(u => u.id == leaderboardItem.user_id));
                 GameLeaderboardItemHeader leaderboardItemHeader = new GameLeaderboardItemHeader(leaderboardItem, user, leaderboardType, index + 1);
                 leaderboardItemHeaderList.Add(leaderboardItemHeader);
             }
             this.LeaderboardType = leaderboardType;
             this.GameLeaderboard = new List <GameLeaderboardItemHeader>((IEnumerable <GameLeaderboardItemHeader>)Enumerable.Take <GameLeaderboardItemHeader>(leaderboardItemHeaderList, 10));
         }
         else if (resultData.activity != null && !((IList)resultData.activity.items).IsNullOrEmpty())
         {
             List <VKClient.Audio.Base.DataObjects.GameActivity> items = resultData.activity.items;
             List <GameActivityHeader> gameActivityHeaderList          = new List <GameActivityHeader>();
             List <VKClient.Audio.Base.DataObjects.GameActivity> .Enumerator enumerator = items.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     VKClient.Audio.Base.DataObjects.GameActivity activity = enumerator.Current;
                     Game game = (Game)Enumerable.FirstOrDefault <Game>(resultData.activity.apps, (Func <Game, bool>)(app => app.id == activity.app_id));
                     User user = (User)Enumerable.FirstOrDefault <User>(resultData.activity.profiles, (Func <User, bool>)(u => u.id == activity.user_id));
                     GameActivityHeader gameActivityHeader = new GameActivityHeader(activity, game, user);
                     gameActivityHeaderList.Add(gameActivityHeader);
                 }
             }
             finally
             {
                 enumerator.Dispose();
             }
             this.GameActivity = new List <GameActivityHeader>((IEnumerable <GameActivityHeader>)gameActivityHeaderList);
         }
         if (resultData.requests == null || ((IList)resultData.requests.items).IsNullOrEmpty())
         {
             return;
         }
         List <GameRequest> items1 = resultData.requests.items;
         List <GameRequestHeader> gameRequestHeaderList = new List <GameRequestHeader>();
         IEnumerator <GameRequest> enumerator1          = ((IEnumerable <GameRequest>)Enumerable.Where <GameRequest>(items1, (Func <GameRequest, bool>)(request => request.type != "invite"))).GetEnumerator();
         try
         {
             while (((IEnumerator)enumerator1).MoveNext())
             {
                 GameRequest request = enumerator1.Current;
                 Game game           = (Game)Enumerable.FirstOrDefault <Game>(resultData.requests.apps, (Func <Game, bool>)(app => app.id == request.app_id));
                 User user           = (User)Enumerable.FirstOrDefault <User>(resultData.requests.profiles, (Func <User, bool>)(u => u.id == request.from_id));
                 GameRequestHeader gameRequestHeader = new GameRequestHeader(request, game, user);
                 gameRequestHeaderList.Add(gameRequestHeader);
             }
         }
         finally
         {
             if (enumerator1 != null)
             {
                 ((IDisposable)enumerator1).Dispose();
             }
         }
         this.GameRequests = new List <GameRequestHeader>((IEnumerable <GameRequestHeader>)gameRequestHeaderList);
     }));
 }