public void SetValues(dreamloLeaderBoard.Score score) { PositionTxt.SetText(String.Format("{0,4}.", score.id)); ScoreTxt.SetText(String.Format("{0,6}", score.score)); NameTxt.SetText(score.playerName); DateTxt.SetText(score.dateString); }
private void AfterUpload() { personalHighscore = highscore.GetPersonalRanking(); topFive = highscore.GetTopFive(); highscoreMenu.ShowOnlineHighscores(topFive, personalHighscore, previousBest, highscore.gameScore); }
public void ShowOnlineHighscores(List <dreamloLeaderBoard.Score> top5, dreamloLeaderBoard.Score personalHighscore, dreamloLeaderBoard.Score previousBest, int currentScore) { enterNamePanel.SetActive(false); onlinePanel.SetActive(true); if (previousBest.playerName != null) { ShowPreviousHighscore(previousBest, currentScore); } ClearHighscoresFromPanel(highscorePanel); bool isInTop5 = false; foreach (var score in top5) { var highscore = Instantiate(highscorePrefab, highscorePanel.transform); highscore.SetValues(score); if (personalHighscore.id == score.id) { isInTop5 = true; highscore.SetColor(colors.accent); } } if (isInTop5) { ownHighscorePanel.SetActive(false); } else { ownHighscorePanel.SetActive(true); ownHighscore.SetValues(personalHighscore); ownHighscore.SetColor(colors.accent); } }
public bool showLeaderboard(string playerUniqueName, string playerInitials, int finalScore, List <dreamloLeaderBoard.Score> scoreList) { if (scoreList.Count == 0) { _leaderboardIndexs.text = ""; _leaderboardInitials.text = ""; _leaderboardScores.text = ""; return(false); } string indexes = ""; string initials = ""; string scores = ""; const int NUM_ENTRIES = 10; string PREFIX = "<color=#" + ColorUtility.ToHtmlStringRGBA(color2) + ">"; const string SUFFIX = "</color>"; int place = GameManager.inst.findPlayerPlace(); bool scoreUpdated = place >= 0; int n = Mathf.Min(NUM_ENTRIES, scoreList.Count); for (int i = 0; i < n; i++) { dreamloLeaderBoard.Score item = scoreList[i]; int j = i; if (j == NUM_ENTRIES - 1 && place >= NUM_ENTRIES) { j = place; item = scoreList[place]; } string playerName = item.shortText; int score = item.score; // we make sure we show the new result if (j == place && score <= finalScore) { scoreUpdated = false; } string prefix = place == j ? PREFIX : ""; string suffix = place == j ? SUFFIX : ""; indexes += prefix + (j + 1) + suffix + "\n"; initials += prefix + playerName + suffix + "\n"; scores += prefix + score + suffix + "\n"; } _leaderboardIndexs.text = indexes; _leaderboardInitials.text = initials; _leaderboardScores.text = scores; return(scoreUpdated); }
public dreamloLeaderBoard.Score GetPersonalRanking() { List <dreamloLeaderBoard.Score> highscore = dreamlo.ToListHighToLow(); dreamloLeaderBoard.Score currentRanking = highscore.Find(score => score.playerName == playerName); if (currentRanking.playerName == null) { Debug.LogWarning("Dreamlo: Personal ranking could not be retrieved! "); } return(currentRanking); }
public void getName() { playerName = name.text; dreamloLeaderBoard.Score sc = new dreamloLeaderBoard.Score(); sc.playerName = playerName; sc.score = GameObject.FindGameObjectWithTag("Player").GetComponent <BeeManager>().CurrentScore; scoreList.Add(sc); overWriteSc(); dl.AddScore(playerName, GameObject.FindGameObjectWithTag("Player").GetComponent <BeeManager>().CurrentScore); }
public int findPlayerPlace() { for (int i = 0; i < _scoreList.Count; i++) { dreamloLeaderBoard.Score item = _scoreList[i]; if (item.playerName.Equals(_playerUniqueName)) { return(i); } } return(-1); }
private void ReturnPersonalBest() { List <dreamloLeaderBoard.Score> highscore = dreamlo.ToListHighToLow(); if (highscore.Count > 0) { dreamloLeaderBoard.Score previousBest = highscore.Find(score => score.playerName == playerName); returnPersonalBestAction(previousBest); } else { Debug.LogWarning("Dreamlo: Previous Highscore List could not be loaded (this is ok if it is your first time playing with this name)"); } }
public void addScore() { submit.SetActive(false); dl.AddScore(pseudo.text, hud.score); dreamloLeaderBoard.Score score = new dreamloLeaderBoard.Score(); score.playerName = pseudo.text; score.score = hud.score; scoreList.Add(score); //Reorder scoreList.Sort((x, y) => y.score.CompareTo(x.score)); //Clean board foreach (Transform child in scorePanel.transform) { Destroy(child.gameObject); } populateBoard(); Debug.Log("submit"); }
private void ShowPreviousHighscore(dreamloLeaderBoard.Score previousScore, int currentScore) { previousHighscorePanel.SetActive(true); previousDateTxt.SetText(previousScore.dateString); previousScoreTxt.SetText(previousScore.score.ToString()); int difference = currentScore - previousScore.score; previousDifferenceTxt.SetText(string.Format("{0,4}", difference.ToString("+#;-#;+/-0"))); if (difference > 0) { previousDifferenceTxt.color = colors.positive; } else if (difference < 0) { previousDifferenceTxt.color = colors.negative; } else { previousDifferenceTxt.color = Color.white; } }
private void GotPreviousBest(dreamloLeaderBoard.Score previousBest) { this.previousBest = previousBest; highscore.UploadScore(AfterUpload); // once this is finished call action to receive rest and display }