Esempio n. 1
0
        public void AddEntry(ScoreboardEntryData scoreboardEntryData)
        {
            ScoreboardSaveData  savedScores = GetSavedScores();
            ScoreboardEntryData hashedScoreboardEntryData = CreateIntegrityHash(scoreboardEntryData);

            Debug.Log("Adding new score entry...");

            bool scoreAdded = false;

            for (int i = 0; i < savedScores.highscores.Count; i++)
            {
                if (hashedScoreboardEntryData.entryScore > savedScores.highscores[i].entryScore)
                {
                    savedScores.highscores.Insert(i, hashedScoreboardEntryData);
                    scoreAdded = true;
                    break;
                }
            }

            if (!scoreAdded && savedScores.highscores.Count < maxScoreboardEntries)
            {
                savedScores.highscores.Add(hashedScoreboardEntryData);
            }

            if (savedScores.highscores.Count > maxScoreboardEntries)
            {
                savedScores.highscores.RemoveRange(maxScoreboardEntries, savedScores.highscores.Count - maxScoreboardEntries);
            }

            UpdateUI(savedScores);
            SaveScores(savedScores);

            Debug.Log("New entry added succesfully");
        }
Esempio n. 2
0
        private ScoreboardEntryData CreateIntegrityHash(ScoreboardEntryData scoreboardEntryData)
        {
            string combinedValues = scoreboardEntryData.entryName + scoreboardEntryData.entryScore.ToString();

            scoreboardEntryData.entryHash = HashString(combinedValues);
            return(scoreboardEntryData);
        }
Esempio n. 3
0
        private ScoreboardEntryData CheckHighScore(ScoreboardEntryData highscore)
        {
            string combinedValues = highscore.entryName + highscore.entryScore.ToString();
            string hashedString   = HashString(combinedValues);

            if (highscore.entryHash != hashedString)
            {
                highscore.entryName  = "1337Haxx0r";
                highscore.entryScore = 0;
                highscore.entryHash  = HashString(highscore.entryName + highscore.entryScore.ToString());
            }

            return(highscore);
        }
Esempio n. 4
0
 public void Initialise(ScoreboardEntryData scoreboardEntryData)
 {
     entryNameText.text  = scoreboardEntryData.entryName;
     entryScoreText.text = scoreboardEntryData.entryScore.ToString();
 }