コード例 #1
0
ファイル: Scoreboard.cs プロジェクト: AlexDonisthorpe/Orbz
        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");
        }
コード例 #2
0
ファイル: Scoreboard.cs プロジェクト: AlexDonisthorpe/Orbz
        private ScoreboardEntryData CreateIntegrityHash(ScoreboardEntryData scoreboardEntryData)
        {
            string combinedValues = scoreboardEntryData.entryName + scoreboardEntryData.entryScore.ToString();

            scoreboardEntryData.entryHash = HashString(combinedValues);
            return(scoreboardEntryData);
        }
コード例 #3
0
ファイル: Scoreboard.cs プロジェクト: AlexDonisthorpe/Orbz
        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);
        }
コード例 #4
0
 public void Initialise(ScoreboardEntryData scoreboardEntryData)
 {
     entryNameText.text  = scoreboardEntryData.entryName;
     entryScoreText.text = scoreboardEntryData.entryScore.ToString();
 }