private async void UploadScore() { try { int homeBaseCount = m_LevelManager.numberOfHomeBases; PlayerHomeBase[] homeBases = m_LevelManager.playerHomeBases; float totalRemainingHealth = 0f; for (int i = 0; i < homeBaseCount; i++) { Damageable config = homeBases[i].configuration; totalRemainingHealth += config.currentHealth; } LCUser user = await LCUser.GetCurrent(); if (user != null) { Dictionary <string, double> statistics = new Dictionary <string, double> { { "GameScore", totalRemainingHealth } }; await LCLeaderboard.UpdateStatistics(user, statistics, false); } } catch (LCException e) { Debug.LogError($"{e.Code} : {e.Message}"); } }
public async Task GetResults() { LCLeaderboard leaderboard = LCLeaderboard.CreateWithoutData(leaderboardName); ReadOnlyCollection <LCRanking> rankings = await leaderboard.GetResults(); foreach (LCRanking ranking in rankings) { WriteLine($"{ranking.Rank} : {ranking.User.ObjectId}, {ranking.Value}"); } }
public async Task Create() { try { LCLeaderboard oldLeaderboard = LCLeaderboard.CreateWithoutData(leaderboardName); await oldLeaderboard.Destroy(); } catch (Exception e) { WriteLine(e.Message); } LCLeaderboard leaderboard = await LCLeaderboard.CreateLeaderboard(leaderboardName); Assert.AreEqual(leaderboard.StatisticName, leaderboardName); }
private async void Reload() { LCLeaderboard leaderboard = LCLeaderboard.CreateWithoutData(LeaderboadName); ReadOnlyCollection <LCRanking> rankings = await leaderboard.GetResults(limit : 10, selectUserKeys : new string[] { "nickname" }); foreach (LCRanking ranking in rankings) { LCUser user = ranking.User; Debug.Log($"{user.GetNickname()} : ${ranking.Value}"); } scrollRect.SetItemData(rankings); }
public async Task GetStatistics() { int today = DateTimeOffset.Now.DayOfYear; string username = $"{today}_0"; string password = "******"; LCUser user = await LCUser.Login(username, password); ReadOnlyCollection <LCStatistic> statistics = await LCLeaderboard.GetStatistics(user); foreach (LCStatistic statistic in statistics) { WriteLine($"{statistic.Name} : {statistic.Value}"); } }
public async Task GetResultsOfMe() { int today = DateTimeOffset.Now.DayOfYear; string username = $"{today}_0"; string password = "******"; await LCUser.Login(username, password); LCLeaderboard leaderboard = LCLeaderboard.CreateWithoutData(leaderboardName); ReadOnlyCollection <LCRanking> rankings = await leaderboard.GetResultsAroundUser(limit : 5); foreach (LCRanking ranking in rankings) { WriteLine($"{ranking.Rank} : {ranking.User.ObjectId}, {ranking.Value}"); } }
public async void FakePlay() { try { LCUser user = await LCUser.GetCurrent(); int score = Random.Range(1, 10); Dictionary <string, double> statistics = new Dictionary <string, double> { { LeaderboadName, score } }; await LCLeaderboard.UpdateStatistics(user, statistics, false); Reload(); } catch (LCException e) { Debug.Log($"{e.Code} : {e.Message}"); } }
public async Task Update() { for (int i = 0; i < 10; i++) { int today = DateTimeOffset.Now.DayOfYear; string username = $"{today}_{i}"; string password = "******"; LCUser user; try { user = await LCUser.Login(username, password); } catch (Exception) { user = new LCUser { Username = username, Password = password }; await user.SignUp(); } await LCLeaderboard.UpdateStatistics(user, new Dictionary <string, double> { { leaderboardName, i * 10 } }); } }