Пример #1
0
        void ISocialPlatform.LoadScores(ILeaderboard board, System.Action <bool> callback)
        {
            if (!VerifyUser())
            {
                return;
            }
            // Fill in fake server side data on leaderboard
            Leaderboard thisBoard = (Leaderboard)board;

            foreach (Leaderboard lb in m_Leaderboards)
            {
                // TODO: In the real world the board might have thousands of scores but only 100
                // are returned, for now we can assume they are less than 100 here
                // TODO: Apply the filters which the leaderboard has, right now it always returns everything found
                if (lb.id == thisBoard.id)
                {
                    thisBoard.SetTitle(lb.title);
                    thisBoard.SetScores(lb.scores);
                    thisBoard.SetMaxRange((uint)lb.scores.Length);
                }
            }
            SortScores(thisBoard);
            SetLocalPlayerScore(thisBoard);
            if (callback != null)
            {
                callback(true);
            }
        }
Пример #2
0
        public void LoadScores(ILeaderboard board, Action <bool> callback)
        {
            if (!this.IsAuthenticated())
            {
                Logger.e("LoadScores can only be called after authentication.");
                if (callback != null)
                {
                    callback(false);
                }
            }
            LeaderboardTimeSpan timeSpan;

            switch ((int)board.get_timeScope())
            {
            case 0:
                timeSpan = LeaderboardTimeSpan.Daily;
                break;

            case 1:
                timeSpan = LeaderboardTimeSpan.Weekly;
                break;

            case 2:
                timeSpan = LeaderboardTimeSpan.AllTime;
                break;

            default:
                timeSpan = LeaderboardTimeSpan.AllTime;
                break;
            }
            ((PlayGamesLeaderboard)board).loading = true;
            Logger.d("LoadScores, board=" + (object)board + " callback is " + (object)callback);
            this.mClient.LoadScores(board.get_id(), LeaderboardStart.PlayerCentered, board.get_range().count <= 0 ? this.mClient.LeaderboardMaxResults() : (int)board.get_range().count, board.get_userScope() != 1 ? LeaderboardCollection.Public : LeaderboardCollection.Social, timeSpan, (Action <LeaderboardScoreData>)(scoreData => this.HandleLoadingScores((PlayGamesLeaderboard)board, scoreData, callback)));
        }
Пример #3
0
    void CheckForHighscore()
    {
        lb    = PlayGamesPlatform.Instance.CreateLeaderboard();
        lb.id = GPGSIds.leaderboard_defenders_of_the_white_house;
        lb.LoadScores(ok =>
        {
            if (ok)
            {
                Debug.Log(lb.localUserScore.formattedValue);
                if (PlayerPrefs.GetInt("HighScore") > int.Parse(lb.localUserScore.formattedValue))
                {
                    PushScoreToTheBoard(PlayerPrefs.GetInt("HighScore"));
                }
                else
                {
                    PlayerPrefs.SetInt("HighScore", int.Parse(lb.localUserScore.formattedValue));
                }
            }
            else
            {
                Debug.Log("Error retrieving leaderboardi");
            }
        });

        if (SceneManager.GetActiveScene().name == "LoadScene")
        {
            GameObject.Find("Curtain").GetComponent <PreLoadScript>().LoadComplete();
        }
    }
Пример #4
0
 public Leaderboard(ILeaderboard leaderboard, DiscordSocketClient client, IChallenges challenges, ISolutions solutions)
 {
     _leaderboard = leaderboard;
     _client      = client;
     _challenges  = challenges;
     _solutions   = solutions;
 }
Пример #5
0
    private void CreateLeaderboardInstance()
    {
        /*
         * Note:
         * CreateLeaderboardInstance() can be called elsewhere in case the player's user data changes during gameplay.
         * It may be best to connect to the button that will display the leaderboard or it can be called right after the
         * player submits a new high score to the leaderboard, which might make the most sense because then it will re-evaluate
         * the user's data and load the appropriate rank range of the leaderboard.
         *
         */

        DisplayDebugLog("Creating an instance of the Game Center leaderboard...");

        // Create an instance of the Game Center leaderboard using the ILeaderboard leaderboard variable and initialize its id and range
        leaderboard = Social.CreateLeaderboard();

#if UNITY_ANDROID
        leaderboard.id = gpgsLeaderboardID;
#endif

#if UNITY_IOS
        leaderboard.id = iosLeaderboardID;
#endif

        // Set the desired range for the leaderboard
        leaderboard.range = LocalTen();

        DisplayDebugLog("Leaderboard instance created.");

        // Load the leaderboard scores once the leaderboard has been initialized
        ProcessLoadedScores();

        // Note: Scores are loaded before the user profiles because the order/ranking is based on scores, not usernames
    }
Пример #6
0
	/// <summary>
	/// Loads the scores.
	/// </summary>
	/// <param name="leaderboard">
	/// Leaderboard.
	/// </param>
	/// <param name="callback">
	/// Callback.
	/// </param>
	public void LoadScores (ILeaderboard leaderboard, Action<bool> callback)
	{
		LoadScores(leaderboard.id,
			scores => {
				callback(scores != null);
			});
	}
Пример #7
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.ChessAI          = new ChessAI(this);
     this.ChessTest        = new ChessTest(this);
     this.Leaderboard      = new Leaderboard(this);
     this.BaseUri          = new Uri("https://magicianschessapi.azurewebsites.net");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
Пример #8
0
        public void LoadScores(ILeaderboard board, Action <bool> callback)
        {
            bool flag = !this.VerifyAuthentication();

            if (flag)
            {
                bool flag2 = callback != null;
                if (flag2)
                {
                    callback(false);
                }
            }
            else
            {
                Leaderboard   leaderboard   = (Leaderboard)board;
                GcLeaderboard gcLeaderboard = new GcLeaderboard(leaderboard);
                GameCenterPlatform.m_GcBoards.Add(gcLeaderboard);
                string[] array = leaderboard.GetUserFilter();
                bool     flag3 = array.Length == 0;
                if (flag3)
                {
                    array = null;
                }
                gcLeaderboard.Internal_LoadScores(board.id, board.range.from, board.range.count, array, (int)board.userScope, (int)board.timeScope, callback);
            }
        }
Пример #9
0
  void init() {
    friendScoreLoaded = false;
#if UNITY_EDITOR
    testMode = true;
#endif
    if (testMode) {
      // Test values for Unity Editor
      IScore[] testScores = new IScore[4];
      for (int i = 0; i < testScores.Length; i++) {
        testScores[i] = new IScoreTestImpl(50 * i, testScores.Length - i, "TEST_USER_" + i);
      }
      scores = testScores;
      SocialPlatformManager.cache.myProfile = new IUserProfileTestImpl("TESTMYSELF", null, false, "TEST_MYSELF!!!");
      friendScoreLoaded = true;
    } else {
      if (SocialPlatformManager.isAuthenticated()) {
        lb = Social.CreateLeaderboard();
        lb.id = SocialPlatformManager.spm.leaderboardInfoMap[AchievementManager.LB_SINGLE];
        lb.range = new Range(1, SocialPlatformManager.cache.MaxLoadCount);
        lb.userScope = SocialPlatformManager.cache.userScope;
        lb.timeScope = TimeScope.AllTime;
        lb.LoadScores(loadFriendScores);
      }
    }
  }
Пример #10
0
        public string GenerateHTMLLeaderBoards(ILeaderboard leaderboard)
        {
            string outputString = $"\n<!-- START OF {leaderboard.GameName} -->\n";

            outputString += "<div class=score-table>\n";
            outputString += $"\t<h1>{leaderboard.GameName}</h1>\n";

            outputString += "\t<table class=\"table table-striped table-dark\">\n";
            outputString += "\t\t<thead>\n\t\t\t<tr>\n";

            string[] tableHeaders = new string[] { "Position", "Name", "Games Played", "Points", "Avg." };
            foreach (var tableHeader in tableHeaders)
            {
                outputString += $"\t\t\t\t<th scope=\"col\">{tableHeader}</th>\n";
            }

            outputString += "\t\t\t</tr>\n";
            outputString += "\t\t</thead>\n\t\t<tbody>\n";

            int position = 1;

            foreach (var player in leaderboard.Players)
            {
                outputString += "\t\t\t<tr> \n";
                outputString += $"\t\t\t\t<td>{position++}</td>\n";
                outputString += $"\t\t\t\t<td>{player.Name}</td>\n";
                outputString += $"\t\t\t\t<td>{player.GamesPlayed}</td>\n";
                outputString += $"\t\t\t\t<td>{player.Points}</td>\n";
                outputString += $"\t\t\t\t<td>{player.Average}</td>\n";
            }
            outputString = outputString + "\t\t\t</tr>\n";

            return(outputString + $"\t\t</tbody>\n\t</table>\n</div>\n<!--END OF {leaderboard.GameName} -->\n");
        }
Пример #11
0
 void ProcessAuthentication(bool success)
 {
     if (success)
     {
         ILeaderboard leaderboard = Social.CreateLeaderboard();
         leaderboard.id = leaderboardID;
         leaderboard.LoadScores(yes => {
             if (yes)
             {
                 IScore[] scores = leaderboard.scores;
                 foreach (IScore iscore in scores)
                 {
                     int value = (int)iscore.value;
                     Debug.Log(value);
                     if (iscore.userID == Social.localUser.id)
                     {
                         if (value > score)
                         {
                             PlayerPrefs.SetInt("Highscore", value);
                             UpdateText();
                         }
                         if (value < score)
                         {
                             //report score
                         }
                     }
                 }
             }
             else
             {
                 Debug.Log("No scores loaded");
             }
         });
     }
 }
        // This function gets called when Authenticate completes
        // Note that if the operation is successful, Social.localUser will contain data from the server.
        public static void ProcessAuthentication(bool success)
        {
            if (success)
            {
                Debug.Log("Authenticated, loading leaderboard");

                // Request loaded achievements, and register a callback for processing them
//            Social.LoadAchievements (ProcessLoadedAchievements);

                ILeaderboard leaderboard = Social.CreateLeaderboard();
#if UNITY_IPHONE
                leaderboard.id = "indeep_101";
#else
                leaderboard.id = "CgkIqb-bqeIPEAIQAQ";
#endif
//			leaderboard.LoadScores (result => {
//				Debug.Log("Received " + leaderboard.scores.Length + " scores");
//				foreach (IScore score in leaderboard.scores)
//					Debug.Log(score);
//			});
            }
            else
            {
                Debug.Log("Failed to authenticate");
            }
        }
Пример #13
0
        public async Task ReplyLeaderboardAsync(ILeaderboard leaderboard)
        {
            List <string> lines = new List <string>(leaderboard.Select(item => {
                int rankWidth  = leaderboard.Count().ToString().Length;
                int scoreWidth = leaderboard.Max(i => i.Score).ToString().Length;

                return(string.Format("**`{0}.`**{1}`{2}` {3}",
                                     item.Rank.ToString("0".PadRight(rankWidth, '0')),
                                     item.Icon,
                                     item.Score.ToString("0".PadRight(scoreWidth, '0')),
                                     string.Format(item.Rank <= 3 ? "**{0}**" : "{0}", string.IsNullOrEmpty(item.Name) ? "Results" : item.Name.ToTitle())
                                     ));
            }));

            IEnumerable <Discord.Messaging.IEmbed> pages = EmbedUtilities.CreateEmbedPages(string.Empty, lines, itemsPerPage: 20, columnsPerPage: 1, options: EmbedPaginationOptions.AddPageNumbers);

            string title = leaderboard.Title;

            if (string.IsNullOrWhiteSpace(title))
            {
                title = "Leaderboard";
            }

            title = $"🏆 {title.ToTitle()} ({lines.Count()})";

            foreach (Discord.Messaging.IEmbed page in pages)
            {
                page.Title = title;
            }

            await ReplyAsync(new PaginatedMessage(pages));
        }
Пример #14
0
 /// <summary>
 /// Loads the scores.
 /// </summary>
 /// <param name="leaderboard">
 /// Leaderboard.
 /// </param>
 /// <param name="callback">
 /// Callback.
 /// </param>
 public void LoadScores(ILeaderboard leaderboard, Action <bool> callback)
 {
     LoadScores(leaderboard.id,
                scores => {
         callback(scores != null);
     });
 }
Пример #15
0
    public void getHighestScore()
    {
                #if UNITY_ANDROID
        //leaderboardID = ANDROIDlbID1;
        leaderboardID = AndroidLBName;
                #elif UNITY_IPHONE
        //leaderboardID = IOSlbID1;
        leaderboardID = IOSLBName;
                #endif

        ILeaderboard lb = Social.CreateLeaderboard();
        lb.id = leaderboardID;
        lb.SetUserFilter(new string[] { Social.localUser.id });
        lb.LoadScores((bool success) => {
            if (success)
            {
                if (lb.scores.Length > 0)
                {
                    Debug.Log("Got user's score: " + lb.scores.GetValue(0).ToString());
                }
                else
                {
                    Debug.Log("lb.scores.Length is 0.");
                }
            }
            else
            {
                Debug.Log("Did not get the user's score.");
            }
        });
    }
Пример #16
0
        void ISocialPlatform.LoadScores(ILeaderboard board, Action <bool> callback)
        {
            if (!this.VerifyUser())
            {
                return;
            }
            Leaderboard board1 = (Leaderboard)board;

            using (List <Leaderboard> .Enumerator enumerator = this.m_Leaderboards.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Leaderboard current = enumerator.Current;
                    if (current.id == board1.id)
                    {
                        board1.SetTitle(current.title);
                        board1.SetScores(current.scores);
                        board1.SetMaxRange((uint)current.scores.Length);
                    }
                }
            }
            this.SortScores(board1);
            this.SetLocalPlayerScore(board1);
            if (callback == null)
            {
                return;
            }
            callback(true);
        }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     _text      = GetComponent <Text>();
     _text.text = "Loading Top 5 leaderboard";
     lb         = Social.CreateLeaderboard();
     lb.id      = "CgkI0tnNw8EVEAIQAQ";
     getTopFive();
 }
Пример #18
0
 public bool GetLoading(ILeaderboard board)
 {
     if (board != null)
     {
         return(board.get_loading());
     }
     return(false);
 }
Пример #19
0
 bool ISocialPlatform.GetLoading(ILeaderboard board)
 {
     if (!VerifyUser())
     {
         return(false);
     }
     return(((Leaderboard)board).loading);
 }
Пример #20
0
 public InMemoryScheduler(IChallenges challenges, ISolutions solutions, IBroadcast broadcaster, ILeaderboard leaderboard, DiscordSocketClient client)
 {
     _challenges  = challenges;
     _solutions   = solutions;
     _broadcaster = broadcaster;
     _client      = client;
     _leaderboard = leaderboard;
 }
Пример #21
0
 /// <summary>
 /// Not implemented yet. Calls the callback with <c>false</c>.
 /// </summary>
 public void LoadScores(ILeaderboard board, Action <bool> callback)
 {
     Logger.w("PlayGamesPlatform.LoadScores not implemented.");
     if (callback != null)
     {
         callback.Invoke(false);
     }
 }
 /// <summary>
 /// Loads the scores of a Leaderboard.
 /// </summary>
 /// <param name="board">Board.</param>
 /// <param name="callback">Callback.</param>
 /// <example>
 /// Example of usage:
 /// <code>
 /// Leaderboard myLeaderboard = CombuManager.platform.CreateLeaderboard();
 /// myLeaderboard.id = "123";
 /// myLeaderboard.timeScope = UnityEngine.SocialPlatforms.TimeScope.AllTime;
 /// myLeaderboard.range = new UnityEngine.SocialPlatforms.Range(1, 10);
 /// CombuManager.platform.LoadScores (myLeaderboard, (bool success) => {
 ///    Debug.Log("LoadScores: " + success);
 /// });
 /// </code>
 /// </example>
 public virtual void LoadScores(ILeaderboard board, System.Action <bool> callback)
 {
     if (!CombuManager.isInitialized)
     {
         throw new System.Exception("Combu Manager not initialized");
     }
     board.LoadScores(callback);
 }
Пример #23
0
 public ValuesController(IEnumerable <IGamingService> gamingServices, IPurchasingService purchasingService, IUnitOfWork unitOfWork, ILeaderboard <UserModel> leaderboard, ConcreteService concreteService)
 {
     _gamingService     = gamingServices;
     _purchasingService = purchasingService;
     _unitOfWork        = unitOfWork;
     _leaderboard       = leaderboard;
     _concreteService   = concreteService;
 }
 /// <summary>
 /// Gets the loading state of a Leaderboard.
 /// </summary>
 /// <returns><c>true</c>, if loading was gotten, <c>false</c> otherwise.</returns>
 /// <param name="board">Board.</param>
 /// <example>
 /// Example of usage:
 /// <code>
 /// Debug.Log("LoadFriends: " + CombuManager.platform.GetLoading(myLeaderboard));
 /// </code>
 /// </example>
 public virtual bool GetLoading(ILeaderboard board)
 {
     if (!CombuManager.isInitialized)
     {
         throw new System.Exception("Combu Manager not initialized");
     }
     return(board.loading);
 }
Пример #25
0
 // Use this for initialization
 void Start()
 {
     _text = GetComponent<Text>();
     _text.text = "Loading Top 5 leaderboard";
     lb = Social.CreateLeaderboard();
     lb.id = "CgkI0tnNw8EVEAIQAQ";
     getTopFive();
 }
Пример #26
0
        internal iOSLeaderboard(string _identifier)
        {
            // Initialize properties
            m_leaderboardData = Social.CreateLeaderboard();
            Identifier        = _identifier;

            // Set initial properties
            m_leaderboardData.range = new Range(0, 0);
        }
Пример #27
0
 /// <summary>
 /// Loads the scores.
 /// </summary>
 /// <param name='board'>
 /// Board.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadScores(ILeaderboard board, System.Action <bool> callback)
 {
     // This function doesn't do anything with a null leaderboard.
     if (null == board)
     {
         AGSClient.LogGameCircleError("LoadScores \"board\" argument should not be null");
         return;
     }
     board.LoadScores(callback);
 }
Пример #28
0
 public InMemoryScheduler(IChallenges challenges, ISolutions solutions, IBroadcast broadcaster, ILeaderboard leaderboard, DiscordSocketClient client, IMessages messages, ITrueskillUpdater skillUpdate)
 {
     _challenges  = challenges;
     _solutions   = solutions;
     _broadcaster = broadcaster;
     _client      = client;
     _messages    = messages;
     _skillUpdate = skillUpdate;
     _leaderboard = leaderboard;
 }
Пример #29
0
 /// <summary>
 /// Gets the loading status of the leaderboard.
 /// </summary>
 /// <returns>
 /// The loading.
 /// </returns>
 /// <param name='board'>
 /// If set to <c>true</c> board.
 /// </param>
 public bool GetLoading(ILeaderboard board)
 {
     // This function doesn't do anything with a null leaderboard.
     if (null == board)
     {
         AGSClient.LogGameCircleError("GetLoading \"board\" argument should not be null");
         return(false);
     }
     return(board.loading);
 }
Пример #30
0
    void DoLeaderboard()
    {
        m_Leaderboard = Social.CreateLeaderboard();
        Debug.Log(m_Leaderboard);
        Debug.Log(m_Leaderboard.id);
        //m_Leaderboard = Social.CreateLeaderboard();
        m_Leaderboard.id = leaderboardName;        //leaderboardID;  // YOUR CUSTOM LEADERBOARD NAME

        m_Leaderboard.LoadScores(result => DidLoadLeaderboard(result));
        Debug.Log(m_Leaderboard.id);
    }
Пример #31
0
 public void LoadUsersandScores(ILeaderboard lb)
 {
     ScoreList [0].text = "successfully called load";
     if (lb == null)
     {
         ScoreList [1].text = "but failed to get HS";
     }
     else
     {
         ScoreList [1].text = lb.localUserScore.ToString();
     }
 }
Пример #32
0
    private ILeaderboard GetAllTimeLeaderboard()
    {
        ILeaderboard board = Social.Active.CreateLeaderboard();

#if UNITY_ANDROID
        board.id = "CgkIzIrx5K0SEAIQAQ";
#else
        board.id = "classic_alltime";
#endif
        board.userScope = UserScope.Global;
        return(board);
    }
 void ProcessAuthentication(bool success)
 {
     if (success)
     {
         Social.LoadAchievements(ProcessLoadedAchievements);
         Debug.Log("Creating leaderboard " + LeaderboardName);
         ILeaderboard leaderboard = Social.CreateLeaderboard();
         leaderboard.id = LeaderboardName;
         Debug.Log("Loading scores for leaderboard " + LeaderboardName);
         leaderboard.LoadScores(result => ProcessScores(result, leaderboard));
     }
 }
Пример #34
0
  public void init() {
    if (SocialPlatformManager.isAuthenticated()) {
      Debug.Log("SocialDataCache: Start initializing...");
#if UNITY_IOS
  // Write for Game Center
      lb = Social.CreateLeaderboard();
#elif UNITY_ANDROID
      lb = PlayGamesPlatform.Instance.CreateLeaderboard();
#endif
      lb.id = SocialPlatformManager.spm.leaderboardInfoMap[AchievementManager.LB_SINGLE];
      lb.range = new Range(1, MaxLoadCount);
      lb.userScope = userScope;
      lb.timeScope = TimeScope.AllTime;
      lb.LoadScores(loadFriendScores);
    } else {
      Debug.Log("SocialDataCache: Not authorized yet");
    }
  }
Пример #35
0
		void ISocialPlatform.LoadScores(ILeaderboard board, Action<bool> callback)
		{
			if (!this.VerifyUser())
			{
				return;
			}
			Leaderboard leaderboard = (Leaderboard)board;
			foreach (Leaderboard current in this.m_Leaderboards)
			{
				if (current.id == leaderboard.id)
				{
					leaderboard.SetTitle(current.title);
					leaderboard.SetScores(current.scores);
					leaderboard.SetMaxRange((uint)current.scores.Length);
				}
			}
			this.SortScores(leaderboard);
			this.SetLocalPlayerScore(leaderboard);
			if (callback != null)
			{
				callback(true);
			}
		}
Пример #36
0
 void ISocialPlatform.LoadScores(ILeaderboard board, Action<bool> callback)
 {
   if (!this.VerifyUser())
     return;
   Leaderboard board1 = (Leaderboard) board;
   using (List<Leaderboard>.Enumerator enumerator = this.m_Leaderboards.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       Leaderboard current = enumerator.Current;
       if (current.id == board1.id)
       {
         board1.SetTitle(current.title);
         board1.SetScores(current.scores);
         board1.SetMaxRange((uint) current.scores.Length);
       }
     }
   }
   this.SortScores(board1);
   this.SetLocalPlayerScore(board1);
   if (callback == null)
     return;
   callback(true);
 }
Пример #37
0
		private sealed virtual bool UnityEngine.SocialPlatforms.ISocialPlatform.GetLoading(ILeaderboard board){}
		internal iOSLeaderboard (string _identifier)
		{
			// Initialize properties
			m_leaderboardData			= Social.CreateLeaderboard();
			Identifier					= _identifier;
			
			// Set initial properties
			m_leaderboardData.range		= new Range(0, 0);
		}
Пример #39
0
        /// <summary>
        /// Loads the leaderboard based on the constraints in the leaderboard
        /// object.
        /// <param name="board">The leaderboard object.  This is created by
        /// calling CreateLeaderboard(), and then initialized appropriately.</param>
        /// <param name="callback">callback, returning boolean for success</param>
        /// </summary>
        public void LoadScores(ILeaderboard board, Action<bool> callback)
        {
            if (!IsAuthenticated())
            {
                GooglePlayGames.OurUtils.Logger.e("LoadScores can only be called after authentication.");
                if (callback != null)
                {
                    callback(false);
                }
            }

            LeaderboardTimeSpan timeSpan;
            switch (board.timeScope)
            {
                case TimeScope.AllTime:
                    timeSpan = LeaderboardTimeSpan.AllTime;
                    break;
                case TimeScope.Week:
                    timeSpan = LeaderboardTimeSpan.Weekly;
                    break;
                case TimeScope.Today:
                    timeSpan = LeaderboardTimeSpan.Daily;
                    break;
                default:
                    timeSpan = LeaderboardTimeSpan.AllTime;
                    break;
            }

            ((PlayGamesLeaderboard)board).loading = true;
            GooglePlayGames.OurUtils.Logger.d("LoadScores, board=" + board + " callback is " + callback);
            mClient.LoadScores(
                board.id,
                LeaderboardStart.PlayerCentered,
                board.range.count > 0 ? board.range.count : mClient.LeaderboardMaxResults(),
                board.userScope == UserScope.FriendsOnly ? LeaderboardCollection.Social : LeaderboardCollection.Public,
                timeSpan,
                (scoreData) => HandleLoadingScores(
                    (PlayGamesLeaderboard)board, scoreData, callback));
        }
Пример #40
0
 /// <summary>
 /// Check if the leaderboard is currently loading.
 /// <param name="board">The leaderboard of interest.</param>
 /// <returns>true if loading.</returns>
 /// </summary>
 public bool GetLoading(ILeaderboard board)
 {
     return board != null && board.loading;
 }
Пример #41
0
 bool ISocialPlatform.GetLoading(ILeaderboard board)
 {
   if (!this.VerifyUser())
     return false;
   return ((Leaderboard) board).loading;
 }
 /// <summary>
 /// Not implemented yet. Returns false.
 /// </summary>
 public bool GetLoading(ILeaderboard board)
 {
     return false;
 }
Пример #43
0
 /// <summary>
 /// Gets the loading status of the leaderboard.
 /// </summary>
 /// <returns>
 /// The loading.
 /// </returns>
 /// <param name='board'>
 /// If set to <c>true</c> board.
 /// </param>
 public bool GetLoading(ILeaderboard board)
 {
     // This function doesn't do anything with a null leaderboard.
     if(null == board) {
         AGSClient.LogGameCircleError("GetLoading \"board\" argument should not be null");
         return false;
     }
     return board.loading;
 }
Пример #44
0
		bool ISocialPlatform.GetLoading(ILeaderboard board)
		{
			return this.VerifyUser() && ((Leaderboard)board).loading;
		}
Пример #45
0
        void ProcessAuthentication(bool success)
        {
            if (success) {
                Debug.Log ("Authenticated, checking achievements");

                leaderboard = Social.CreateLeaderboard();
                if (paidVersion) {
                    leaderboard.id = "com.hemant.triplecommaclubpaid";
                } else {
                    leaderboard.id = "com.hemant.triplecommaclub";
                }
                leaderboard.LoadScores(scoreSuccess => {
                    if (scoreSuccess && leaderboard.scores.Length > 0) {
                        Debug.Log ("Got " + leaderboard.scores.Length + " scores");
                        string myScores = "Leaderboard:\n";
                        foreach (IScore score in leaderboard.scores)
                            myScores += "\t" + score.userID + " " + score.formattedValue + " " + score.date + "\n";
                        Debug.Log (myScores);
                    }
                });
            } else {
                Debug.Log ("Failed to authenticate");
            }
        }
        internal void LoadUsersAndDisplay(ILeaderboard lb)
        {
            // get the use ids
            List<string> userIds = new List<string>();

            foreach(IScore score in lb.scores)
            {
                userIds.Add(score.userID);
            }
            Social.LoadUsers(userIds.ToArray(), (users) =>
                {
                    mStatus = "Leaderboard loading: " + lb.title + " count = " +
                        lb.scores.Length;
                    foreach(IScore score in lb.scores) {
                        IUserProfile user = FindUser(users, score.userID);
                        mStatus += "\n" + score.formattedValue + " by " +
                            (string)(
                                (user != null) ? user.userName : "******" + score.userID + "**");
                    }
                });
        }
Пример #47
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void LoadScores(ILeaderboard board, Action<bool> callback)
 {
 }
Пример #48
0
 /// <summary>
 /// Loads the scores.
 /// </summary>
 /// <param name='board'>
 /// Board.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadScores(ILeaderboard board, System.Action<bool> callback)
 {
     // This function doesn't do anything with a null leaderboard.
     if(null == board) {
         AGSClient.LogGameCircleError("LoadScores \"board\" argument should not be null");
         return;
     }
     board.LoadScores(callback);
 }
Пример #49
0
		private sealed virtual void UnityEngine.SocialPlatforms.ISocialPlatform.LoadScores(ILeaderboard board, Action<Boolean> callback){}
 /// <summary>
 /// Not implemented yet. Calls the callback with <c>false</c>.
 /// </summary>
 public void LoadScores(ILeaderboard board, Action<bool> callback)
 {
     Logger.w("PlayGamesPlatform.LoadScores not implemented.");
     if (callback != null)
     {
         callback.Invoke(false);
     }
 }
Пример #51
0
 /************************************************************************************************
 * NAME   : DoLeaderboard
 * ACTION : Called from DoLeaderboard when game center has been authenticated
 * INPUT  : none
 * OUTPUT : none
 *************************************************************************************************/
 void DoLeaderboard()
 {
   Leaderboard = Social.CreateLeaderboard();
   Leaderboard.id = "TorpedoRun_L7";                                                    /* your game centre leaderboard ID goes here */
   D.logx("Loading Leaderboard {0}",Leaderboard.id);
   Leaderboard.range = new Range(1,100);
   Leaderboard.LoadScores(result => DidLoadScores(result));
 }
Пример #52
0
	/// <summary>
	/// Gets whether the specified leaderboard is loading.
	/// </summary>
	/// <param name="leaderboard">The leaderboard in question.</param>
	/// <returns type="bool">True if the leaderboard is currently loading scores.</returns>
	public bool GetLoading (ILeaderboard leaderboard)
	{
		return leaderboard.loading;
	}