Exemple #1
0
        public void addEntry(HighScoreEntryData t_data)
        {
            HighScoreSaveData savedScores = getSavedScores();

            bool scoreAdded = false;

            for (int i = 0; i < savedScores.highScores.Count; i++)
            {
                if (t_data.m_time < savedScores.highScores[i].m_time)
                {
                    savedScores.highScores.Insert(i, t_data);
                    scoreAdded = true;
                    break;
                }
            }

            if (!scoreAdded && savedScores.highScores.Count < MaxEntries)
            {
                savedScores.highScores.Add(t_data);
            }

            if (savedScores.highScores.Count > MaxEntries)
            {
                savedScores.highScores.RemoveRange(MaxEntries, savedScores.highScores.Count - MaxEntries);
            }

            updateUI(savedScores);

            SaveScores(savedScores);
        }
Exemple #2
0
        private void updateUI(HighScoreSaveData t_savedScores)
        {
            foreach (Transform child in highScoreHolderTransform)
            {
                Destroy(child.gameObject);
            }

            int e = 0;

            foreach (HighScoreEntryData highScore in t_savedScores.highScores)
            {
                Instantiate(ScoreEntryObject, highScoreHolderTransform).
                GetComponent <HighScoreUI>().init(highScore, e);
                e++;
            }
        }
Exemple #3
0
        private void SaveScores(HighScoreSaveData t_saveData)
        {
            string json = JsonUtility.ToJson(t_saveData, true);

            File.WriteAllText(SavePath, json);
        }
Exemple #4
0
        private void Start()
        {
            HighScoreSaveData savedScores = getSavedScores();

            updateUI(savedScores);
        }