public leaderboarddata GetLeaderBoardData(int id, ILeaderBoard lb) { leaderboarddata lbd = null; leaderboard dbLb = this.GetLeaderBoard(lb); if (!this.idToLeaderBoardData.TryGetValue(this.GetLookupKey(id, lb.LeaderBoardKey), out lbd)) { lbd = new leaderboarddata { isPlayer = lb.IsPlayerBoard, leaderboard = dbLb, year = this.year }; if (lb.IsPlayerBoard) { lbd.playerId = id; } else { lbd.teamId = id; } dbLb.leaderboarddatas.Add(lbd); this.boardToData[dbLb.key].Add(lbd); } return(lbd); }
// Fetch words and store them public IEnumerator getLeaders() { WWWForm form = new WWWForm(); form.AddField("method", "getTop10"); form.AddField("userid", PlayerPrefs.GetInt("userid")); form.AddField("pack", PlayerPrefs.GetInt("pack")); form.AddField("level", PlayerPrefs.GetString("level")); using (var w = UnityWebRequest.Post("http://nati.games/apis/spellingflea.cfc", form)) { yield return(w.SendWebRequest()); if (w.isNetworkError || w.isHttpError) { print(w.error); } else { var myString = w.downloadHandler.text; leaderboard = JsonUtility.FromJson <leaderboard>(myString); name1.text = leaderboard.name1; name2.text = leaderboard.name2; name3.text = leaderboard.name3; name4.text = leaderboard.name4; name5.text = leaderboard.name5; name6.text = leaderboard.name6; name7.text = leaderboard.name7; name8.text = leaderboard.name8; name9.text = leaderboard.name9; name10.text = leaderboard.name10; yourname.text = leaderboard.nameyou; score1.text = leaderboard.score1; score2.text = leaderboard.score2; score3.text = leaderboard.score3; score4.text = leaderboard.score4; score5.text = leaderboard.score5; score6.text = leaderboard.score6; score7.text = leaderboard.score7; score8.text = leaderboard.score8; score9.text = leaderboard.score9; score10.text = leaderboard.score10; yourscore.text = leaderboard.scoreyou; games1.text = leaderboard.total1; games2.text = leaderboard.total2; games3.text = leaderboard.total3; games4.text = leaderboard.total4; games5.text = leaderboard.total5; games6.text = leaderboard.total6; games7.text = leaderboard.total7; games8.text = leaderboard.total8; games9.text = leaderboard.total9; games10.text = leaderboard.total10; yourgames.text = leaderboard.totalyou; level.text = leaderboard.level; pack.text = leaderboard.packname; } } }
void Start() { for (int i = 0; i < highscoreFields.Length; i++) { highscoreFields[i].text = i + 1 + ". Fetching..."; } highscoresManager = GetComponent <leaderboard>(); StartCoroutine("RefreshHighscores"); }
public LeaderBoardResponse(leaderboard leaderboard, bool includeLeaderBoardData = true) { this.Id = leaderboard.id; this.Name = leaderboard.name; this.Key = leaderboard.key; this.IsPlayerBoard = leaderboard.isPlayerBoard; this.Priority = leaderboard.priority; this.FormatType = leaderboard.formatType; if (includeLeaderBoardData && leaderboard.leaderboarddatas != null) { this.LeaderBoardDatas = leaderboard.leaderboarddatas.Select(x => LeaderBoardDataResponse.From(x)); } }
public leaderboard GetLeaderBoard(ILeaderBoard lb) { leaderboard dbLb = null; if (!keyToLeaderBoard.TryGetValue(lb.LeaderBoardKey, out dbLb)) { dbLb = new leaderboard { key = lb.LeaderBoardKey, isPlayerBoard = lb.IsPlayerBoard, }; dbLb = this.db.leaderboards.Add(dbLb); this.boardToData[dbLb.key] = new HashSet <leaderboarddata>(); keyToLeaderBoard[lb.LeaderBoardKey] = dbLb; } dbLb.name = lb.LeaderBoardName; dbLb.formatType = lb.Format.PersistedKey; dbLb.priority = lb.Priority; return(dbLb); }