private void UpdateSongInfoText(SongMeta selectedSong) { ResetInfoText(); if (selectedSong == null) { return; } LocalStatistic localStats = statistics.GetLocalStats(selectedSong); if (localStats != null) { // Display local highscore SongStatistic localTopScore = localStats.StatsEntries.TopScore; if (localTopScore != null) { SetLocalHighscoreText(localTopScore.PlayerName, localTopScore.Score); } // Display count started/finished SetStartedFinishedText(localStats.TimesStarted, localStats.TimesFinished); } // Display web highscore WebStatistic webStats = statistics.GetWebStats(selectedSong); if (webStats != null) { SongStatistic webTopScore = webStats.StatsEntries.TopScore; if (webTopScore != null) { SetWebHighscoreText(webTopScore.PlayerName, webTopScore.Score); } } }
private void UpdateHighscoreText(SongMeta selectedSong) { ResetHighscoreText(); if (selectedSong == null) { return; } // Display local highscore LocalStatistic localStats = statistics.GetLocalStats(selectedSong); if (localStats != null) { SongStatistic localTopScore = localStats.StatsEntries.TopScore; if (localTopScore != null) { highscoreLocalPlayerText.text = localTopScore.PlayerName; highscoreLocalScoreText.text = localTopScore.Score.ToString(); } } // Display web highscore WebStatistic webStats = statistics.GetWebStats(selectedSong); if (webStats != null) { SongStatistic webTopScore = webStats.StatsEntries.TopScore; if (webTopScore != null) { highscoreWebPlayerText.text = webTopScore.PlayerName; highscoreWebScoreText.text = webTopScore.Score.ToString(); } } }
private void ShowHighscore(UiTopEntry uiTopEntry, SongStatistic songStatistic, int index) { uiTopEntry.indexText.text = (index + 1).ToString(); uiTopEntry.playerNameText.text = songStatistic.PlayerName; uiTopEntry.scoreText.text = songStatistic.Score.ToString(); uiTopEntry.dateText.text = songStatistic.DateTime.ToString("d", CultureInfo.CurrentUICulture); }
private void FillHighscoreEntry(VisualElement highscoreEntry, SongStatistic songStatistic, int index) { highscoreEntry.Q <Label>(R.UxmlNames.posLabel).text = (index + 1).ToString(); highscoreEntry.Q <Label>(R.UxmlNames.playerNameLabel).text = songStatistic.PlayerName; highscoreEntry.Q <Label>(R.UxmlNames.scoreLabel).text = songStatistic.Score.ToString(); highscoreEntry.Q <Label>(R.UxmlNames.dateLabel).text = songStatistic.DateTime.ToString("d", CultureInfo.CurrentUICulture); }
public void RecordSongFinished(SongMeta songMeta, string playerName, EDifficulty difficulty, int score) { Debug.Log("Recording song stats for " + playerName); SongStatistic statsObject = new SongStatistic(playerName, difficulty, score); LocalStatistics.GetOrInitialize(songMeta.SongHash).UpdateSongFinished(statsObject); UpdateTopScores(songMeta, statsObject); IsDirty = true; }
public void RecordSongFinished(SongMeta songMeta, string playerName, EDifficulty difficulty, int score) { Debug.Log("Recording song stats for " + playerName); SongStatistic statsObject = new SongStatistic(playerName, difficulty, score); GetOrInitialize <LocalStatistic>(LocalStatistics, songMeta.SongHash).UpdateSongFinished(statsObject); UpdateTopScores(songMeta, statsObject); TriggerDatabaseWrite(); }
private void UpdateTopScores(SongMeta songMeta, SongStatistic songStatistic) { Debug.Log("Updating top scores"); TopEntry topEntry = new TopEntry(songMeta.Title, songMeta.Artist, songStatistic); //Update the top score if (TopScore == null || songStatistic.Score > TopScore.SongStatistic.Score) { TopScore = topEntry; } //Update the top ten //Find where in the current top ten to place the current score int topTenIndex = -1; for (int i = 0; i < TopTenList.Count; ++i) { if (songStatistic.Score > TopTenList[i].SongStatistic.Score) { topTenIndex = i + 1; break; } } //List isn't full yet, just add the score to the end if (topTenIndex == -1 || TopTenList.Count < 10) { TopTenList.Add(topEntry); } else { //should be fine. an oversight //Otherwise just insert the top score into its respective place TopTenList.Insert(topTenIndex, topEntry); } //Remove any scores beyond the top ten in the list if (TopTenList.Count > 10) { TopTenList = TopTenList.Take(10).ToList(); } }
public void UpdateSongFinished(SongStatistic songStatistic) { StatsEntries.AddRecord(songStatistic); }
public void RemoveRecord(SongStatistic record) { SongStatistics.Remove(record); }
public void AddRecord(SongStatistic record) { SongStatistics.Add(record); }
//Called whenever a song is finished public void UpdateSongFinished(SongStatistic songStatistic) { ++TimesFinished; LastPlayed = DateTime.Now; StatsEntries.AddRecord(songStatistic); }
public TopEntry(string songName, string songArtist, SongStatistic songStatistic) { this.SongName = songName; this.SongArtist = songArtist; this.SongStatistic = songStatistic; }
// Called for every player when a song is finished public void AddSongStatistics(SongStatistic songStatistic) { StatsEntries.AddRecord(songStatistic); }