Ejemplo n.º 1
0
        /// <summary>
        /// Fill the leaderboard panel with nonpaged scores then show it.
        /// </summary>
        /// <param name="scoresList">List of the scores to display.</param>
        /// <param name="noScoreErrorMessage">Error message to display in case of no score to display.</param>
        public void FillNonpagedLeaderboardPanel(NonpagedList <Score> scoresList, string noScoreErrorMessage = "(no score to display)")
        {
            // Clear the leaderboard panel
            ClearLeaderboardPanel(false);

            // If there are scores to display, fill the leaderboard panel with score prefabs
            if ((scoresList != null) && (scoresList.Count > 0))
            {
                foreach (Score score in scoresList)
                {
                    // Create a leaderboard score GameObject and hook it at the leaderboard items layout
                    GameObject prefabInstance = Instantiate <GameObject>(leaderboardScorePrefab);
                    prefabInstance.transform.SetParent(leaderboardItemsLayout.transform, false);

                    // Fill the newly created GameObject with score data
                    LeaderboardScoreHandler leaderboardScoreHandler = prefabInstance.GetComponent <LeaderboardScoreHandler>();
                    leaderboardScoreHandler.FillData(score);

                    // Add the newly created GameObject to the list
                    leaderboardItems.Add(prefabInstance);
                }
            }
            // Else, show the "no score" text
            else
            {
                noScoreText.text = noScoreErrorMessage;
                noScoreText.gameObject.SetActive(true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fill the community panel with friends (or blacklisted gamers).
        /// </summary>
        /// <param name="friendsList">List of the friends to display.</param>
        public void FillCommunityPanel(NonpagedList <GamerInfo> friendsList)
        {
            // Clear the community panel
            ClearCommunityPanel(false);

            // If there are friends to display, fill the community panel with friend prefabs
            if ((friendsList != null) && (friendsList.Count > 0))
            {
                foreach (GamerInfo friend in friendsList)
                {
                    // Create a community friend GameObject and hook it at the community items layout
                    GameObject prefabInstance = Instantiate <GameObject>(communityFriendPrefab);
                    prefabInstance.transform.SetParent(communityItemsLayout.transform, false);

                    // Fill the newly created GameObject with friend data
                    CommunityFriendHandler communityFriendHandler = prefabInstance.GetComponent <CommunityFriendHandler>();
                    communityFriendHandler.FillData(friend["profile"]);

                    // Add the newly created GameObject to the list
                    communityItems.Add(prefabInstance);
                }
            }
            // Else, show the "no friend" text
            else
            {
                noFriendText.SetActive(true);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fill the godfather panel with godchildren list.
        /// </summary>
        /// <param name="godchildrenList">Godchildren gamer info.</param>
        public void FillGodfatherPanel(NonpagedList <GamerInfo> godchildrenList)
        {
            // Clear the godfather panel
            ClearGodfatherPanel(false);

            // If there are godchildren to display, fill the godfather panel with gamer prefabs
            if ((godchildrenList != null) && (godchildrenList.Count > 0))
            {
                foreach (GamerInfo godchild in godchildrenList)
                {
                    // Create a godfather gamer GameObject and hook it at the godfather items layout
                    GameObject prefabInstance = Instantiate <GameObject>(godfatherGamerPrefab);
                    prefabInstance.transform.SetParent(godfatherItemsLayout.transform, false);

                    // Fill the newly created GameObject with gamer data
                    GodfatherGamerHandler godfatherGamerHandler = prefabInstance.GetComponent <GodfatherGamerHandler>();
                    godfatherGamerHandler.FillData(godchild["profile"], godchild.GamerId);

                    // Add the newly created GameObject to the list
                    godfatherItems.Add(prefabInstance);
                }
            }
            // Else, show the "no godchild" text
            else
            {
                noGodchildText.gameObject.SetActive(true);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Fetches the list of transactions made by the logged in user. Only successful transactions
 /// show here.
 /// </summary>
 /// <returns>Promise resolved when the operation has completed. The attached value describes a list of purchase
 ///     transactions, without pagination functionality.</returns>
 public Promise<NonpagedList<PurchaseTransaction>> GetPurchaseHistory()
 {
     return Common.RunInTask<NonpagedList<PurchaseTransaction>>(Gamer.MakeHttpRequest("/v1/gamer/store/purchaseHistory"), (response, task) => {
         var products = new NonpagedList<PurchaseTransaction>(response.BodyJson);
         foreach (Bundle b in response.BodyJson["purchases"].AsArray()) {
             products.Add(new PurchaseTransaction(b));
         }
         task.PostResult(products);
     });
 }
Ejemplo n.º 5
0
 /// <summary>
 /// What to do if any DisplayNonpagedScores request succeeded.
 /// </summary>
 /// <param name="scoresList">List of all gamers' high scores from the given leaderboard.</param>
 /// <param name="noScoreErrorMessage">Error message to display in case of no score to display.</param>
 private static void DisplayNonpagedScores_OnSuccess(NonpagedList <Score> scoresList, string noScoreErrorMessage)
 {
     LeaderboardHandler.Instance.FillNonpagedLeaderboardPanel(scoresList, noScoreErrorMessage);
 }
Ejemplo n.º 6
0
 /// <summary>This method can be used to retrieve the gamer who have added you as a godfather.</summary>
 /// <returns>Promise resolved when the operation has completed.</returns>
 public Promise<NonpagedList<GamerInfo>> GetGodchildren()
 {
     UrlBuilder url = new UrlBuilder("/v2.6/gamer/godchildren").Path(domain);
     HttpRequest req = Gamer.MakeHttpRequest(url);
     return Common.RunInTask<NonpagedList<GamerInfo>>(req, (response, task) => {
         var result = new NonpagedList<GamerInfo>(response.BodyJson);
         foreach (Bundle b in response.BodyJson["godchildren"].AsArray()) {
             result.Add(new GamerInfo(b));
         }
         task.PostResult(result);
     });
 }
 /// <summary>
 /// What to do if any DisplayGodchildren request succeeded.
 /// </summary>
 /// <param name="godchildrenList">List of current logged in gamer's godchildren.</param>
 private static void DisplayGodchildren_OnSuccess(NonpagedList <GamerInfo> godchildrenList)
 {
     GodfatherHandler.Instance.FillGodfatherPanel(godchildrenList);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// What to do if any DisplayFriends request succeeded.
 /// </summary>
 /// <param name="friendsList">List of friends (or blacklisted gamers).</param>
 private static void DisplayFriends_OnSuccess(NonpagedList <GamerInfo> friendsList)
 {
     CommunityHandler.Instance.FillCommunityPanel(friendsList);
 }
Ejemplo n.º 9
0
 /// <summary>Method used to retrieve the application's friends of the currently logged in profile.</summary>
 /// <returns>Promise resolved when the operation has completed, with the fetched list of friends.</returns>
 /// <param name="filterBlacklisted">When set to true, restricts to blacklisted friends.</param>
 public Promise<NonpagedList<GamerInfo>> ListFriends(bool filterBlacklisted = false)
 {
     UrlBuilder url = new UrlBuilder("/v2.6/gamer/friends").Path(domain);
     if (filterBlacklisted) url.QueryParam("status", "blacklist");
     HttpRequest req = Gamer.MakeHttpRequest(url);
     return Common.RunInTask<NonpagedList<GamerInfo>>(req, (response, task) => {
         var result = new NonpagedList<GamerInfo>(response.BodyJson);
         foreach (Bundle f in response.BodyJson["friends"].AsArray()) {
             result.Add(new GamerInfo(f));
         }
         task.PostResult(result);
     });
 }
Ejemplo n.º 10
0
 /// <summary>Fetch the score list for a given board, restricting to the scores made by the friends of the current user.</summary>
 /// <returns>Promise resolved when the operation has completed. The attached value describes a list of scores,
 ///     without pagination functionality.</returns>
 /// <param name="board">The name of the board to fetch scores from.</param>
 public Promise<NonpagedList<Score>> ListFriendScores(string board)
 {
     UrlBuilder url = new UrlBuilder("/v2.6/gamer/scores").Path(domain).Path(board).QueryParam("type", "friendscore");
     return Common.RunInTask<NonpagedList<Score>>(Gamer.MakeHttpRequest(url), (response, task) => {
         var scores = new NonpagedList<Score>(response.BodyJson);
         foreach (Bundle b in response.BodyJson[board].AsArray()) {
             scores.Add(new Score(b));
         }
         task.PostResult(scores);
     });
 }