public static float GetHighScorePercentage(string songID) { //Get the needed data HighScoreRecords.HighScoreInfo highScoreInfo = HighScoreRecords.GetHighScore(songID); float highScore = Convert.ToSingle(highScoreInfo.score); float maxPossibleScore = Convert.ToSingle(starThresholds.GetMaxRawScore(songID, highScoreInfo.difficulty)); //Calculate score percentage float percentage = (highScore / maxPossibleScore) * 100; return(percentage); }
public static void ScoreKeeperDisplayUpdate(ScoreKeeperDisplay scoreKeeperDisplay) { if (!KataConfig.I.practiceMode) { int score = ScoreKeeper.I.mScore; float percentage = GetScorePercentage(selectedSong, score, KataConfig.I.GetDifficulty()); //Make pretty-ish strings string scoreString = "<size=" + inGameCurrentScoreSize + ">" + String.Format("{0:n0}", score).Replace(",", " ") + "</size>"; string percentageString = "<size=" + inGameCurrentPercentSize + "> (" + String.Format("{0:0.00}", percentage) + "%)</size>"; scoreKeeperDisplay.scoreDisplay.text = scoreString + percentageString; HighScoreRecords.HighScoreInfo highScoreInfo = HighScoreRecords.GetHighScore(selectedSong); float highScore = Convert.ToSingle(highScoreInfo.score); float highScorePercentage = GetHighScorePercentage(selectedSong); string highScoreString = "<size=" + inGameHighScoreSize + ">" + String.Format("{0:n0}", highScore).Replace(",", " ") + "</size>"; string highScorePercentageString = "<size=" + inGamePercentSize + "> (" + String.Format("{0:0.00}", highScorePercentage) + "%)</size>"; scoreKeeperDisplay.highScoreDisplay.text = "<size=" + inGameHighScoreLabelSize + ">" + inGameHighScoreLabelText + "</size>" + highScoreString + highScorePercentageString; } }
//Tracking the play history SetTopScore function public static void SetTopScore(SongInfoTopScoreItem item) { SongInfoTopScoreItem topScoreItem = item; //Get percentage float percentage = GetHighScorePercentage(selectedSong); //Make pretty-ish strings string scoreString = "<size=" + historyTopScoreSize + ">" + String.Format("{0:n0}", HighScoreRecords.GetHighScore(selectedSong).score).Replace(",", " ") + "</size>"; string percentageString = "<size=" + historyTopPercentSize + "> (" + String.Format("{0:0.00}", percentage) + "%)</size>"; //Update label topScoreItem.score.text = scoreString + percentageString; }