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 UpdateSongStatistics(SongMeta songMeta)
    {
        LocalStatistic localStatistic = statistics.GetLocalStats(songMeta);

        if (localStatistic != null)
        {
            timesClearedLabel.text = TranslationManager.GetTranslation(R.Messages.songSelectScene_timesClearedInfo,
                                                                       "value", localStatistic.TimesFinished);
            timesCanceledLabel.text = TranslationManager.GetTranslation(R.Messages.songSelectScene_timesCanceledInfo,
                                                                        "value", localStatistic.TimesCanceled);

            List <SongStatistic> topScores       = localStatistic.StatsEntries.GetTopScores(3);
            List <int>           topScoreNumbers = topScores.Select(it => it.Score).ToList();

            UpdateTopScoreLabels(topScoreNumbers, localHighScoreContainer);
            UpdateTopScoreLabels(new List <int>(), onlineHighScoreContainer);
        }
        else
        {
            timesClearedLabel.text  = "";
            timesCanceledLabel.text = "";

            UpdateTopScoreLabels(new List <int>(), localHighScoreContainer);
            UpdateTopScoreLabels(new List <int>(), onlineHighScoreContainer);
        }
    }
    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);
            }
        }
    }
Example #4
0
    private void ShowHighscores(SongMeta songMeta, EDifficulty difficulty)
    {
        currentDifficulty       = difficulty;
        difficultyText.text     = i18nManager.GetTranslation(I18NKeys.difficulty) + ": " + difficulty.GetTranslatedName();
        titleAndArtistText.text = $"{songMeta.Title} - {songMeta.Artist}";

        LocalStatistic       localStatistic = statistics.GetLocalStats(songMeta);
        List <SongStatistic> songStatistics = localStatistic?.StatsEntries?.SongStatistics?
                                              .Where(it => it.Difficulty == difficulty).ToList();

        if (songStatistics.IsNullOrEmpty())
        {
            songStatistics = new List <SongStatistic>();
        }
        songStatistics.Sort(new CompareBySongScoreDescending());
        List <SongStatistic> topSongStatistics = songStatistics.Take(topEntries.Length).ToList();

        for (int i = 0; i < topEntries.Length; i++)
        {
            if (i < topSongStatistics.Count)
            {
                ShowHighscore(topEntries[i], topSongStatistics[i], i);
                topEntries[i].gameObject.SetActive(true);
            }
            else
            {
                topEntries[i].gameObject.SetActive(false);
            }
        }
    }
Example #5
0
    public LocalStatistic GetLocalStats(SongMeta songMeta)
    {
        LocalStatistic result = null;

        LocalStatistics.TryGetValue(songMeta.SongHash, out result);
        return(result);
    }
    private void ShowHighscores(SongMeta songMeta, EDifficulty difficulty)
    {
        currentDifficulty       = difficulty;
        difficultyText.text     = TranslationManager.GetTranslation(R.Messages.difficulty) + ": " + difficulty.GetTranslatedName();
        titleAndArtistText.text = $"{songMeta.Title} - {songMeta.Artist}";

        LocalStatistic       localStatistic = statistics.GetLocalStats(songMeta);
        List <SongStatistic> songStatistics = localStatistic?.StatsEntries?.SongStatistics?
                                              .Where(it => it.Difficulty == difficulty).ToList();

        if (songStatistics.IsNullOrEmpty())
        {
            songStatistics = new List <SongStatistic>();
        }
        songStatistics.Sort(new CompareBySongScoreDescending());
        List <SongStatistic> topSongStatistics = songStatistics.Take(highscoreEntries.Count).ToList();

        for (int i = 0; i < highscoreEntries.Count; i++)
        {
            if (i < topSongStatistics.Count)
            {
                highscoreEntries[i].ShowByDisplay();
                FillHighscoreEntry(highscoreEntries[i], topSongStatistics[i], i);
            }
            else
            {
                highscoreEntries[i].HideByDisplay();
            }
        }

        // update "next difficulty button" text
        UpdateTranslation();
    }
Example #7
0
    private void OnNewSongSelection(SongSelection selection)
    {
        SongMeta selectedSong = selection.SongMeta;

        if (selectedSong == null)
        {
            SetEmptySongDetails();
            return;
        }

        artistText.SetText(selectedSong.Artist);
        songTitleText.text = selectedSong.Title;
        songCountText.text = (selection.SongIndex + 1) + "/" + selection.SongsCount;

        //Display local highscore
        highscoreLocalPlayerText.text = "";
        highscoreLocalScoreText.text  = "0";
        LocalStatistic localStats = statsManager.GetLocalStats(selectedSong);
        SongStatistic  localTopScore;

        if (localStats != null)
        {
            localTopScore = localStats.StatsEntries.TopScore;

            if (localTopScore != null)
            {
                Debug.Log("Found local highscore: " + localTopScore.PlayerName + " " + localTopScore.Score.ToString());
                highscoreLocalPlayerText.text = localTopScore.PlayerName;
                highscoreLocalScoreText.text  = localTopScore.Score.ToString();
            }
        }

        //Display web highscore
        highscoreWebPlayerText.text = "";
        highscoreWebScoreText.text  = "0";
        WebStatistic  webStats = statsManager.GetWebStats(selectedSong);
        SongStatistic webTopScore;

        if (webStats != null)
        {
            webTopScore = webStats.StatsEntries.TopScore;

            if (webTopScore != null)
            {
                Debug.Log("Found web highscore: " + webTopScore.PlayerName + " " + webTopScore.Score.ToString());
                highscoreWebPlayerText.text = webTopScore.PlayerName;
                highscoreWebScoreText.text  = webTopScore.Score.ToString();
            }
        }

        bool hasVideo = !string.IsNullOrEmpty(selectedSong.Video);

        videoIndicator.SetActive(hasVideo);

        bool isDuet = selectedSong.VoiceNames.Count > 1;

        duetIndicator.SetActive(isDuet);
    }
Example #8
0
    public void RecordSongFinished(SongMeta songMeta, List <SongStatistic> songStatistics)
    {
        Debug.Log("Recording song finished stats for: " + songMeta.Title);
        LocalStatistic localStatistic = LocalStatistics.GetOrInitialize(songMeta.SongHash);

        localStatistic.IncrementSongFinished();
        foreach (SongStatistic songStatistic in songStatistics)
        {
            localStatistic.AddSongStatistics(songStatistic);
            UpdateTopScores(songMeta, songStatistic);
        }

        IsDirty = true;
    }