Ejemplo n.º 1
0
    public void Awake()
    {
        TopScoreTracker data = ScoreSaveSystem.LoadScoreList();

        if (data != null)
        {
            for (int i = 0; i < 5; i++)
            {
                string result = "";
                int    length = data.listOfScores[i].ToString().Length;

                for (int j = length; j < 7; j++)
                {
                    result += "0";
                }

                result += data.listOfScores[i];

                highScoreTexts[i].text = (i + 1).ToString() + ". " + result;
            }
        }
        else
        {
            for (int i = 0; i < 5; i++)
            {
                highScoreTexts[i].text = (i + 1).ToString() + ". 000000";
            }
        }
    }
Ejemplo n.º 2
0
    public static void SaveScoreList(HighScoreTracker scoreTracker)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string path = Application.persistentDataPath + "/score.lol";

        FileStream stream = new FileStream(path, FileMode.Create);

        TopScoreTracker topScoreTracker = new TopScoreTracker(scoreTracker);

        formatter.Serialize(stream, topScoreTracker);
        stream.Close();
    }
Ejemplo n.º 3
0
    public void Start()
    {
        highScoreTracker = this;

        highScoreText = GetComponent <Text>();

        TopScoreTracker topScoreTracker = ScoreSaveSystem.LoadScoreList();

        if (topScoreTracker != null)
        {
            highScoreList = topScoreTracker.listOfScores;
        }
        else
        {
            highScoreList = new List <int>();

            for (int i = 0; i < 5; i++)
            {
                highScoreList.Add(0);
            }
        }
    }
Ejemplo n.º 4
0
    public static TopScoreTracker LoadScoreList()
    {
        string path = Application.persistentDataPath + "/score.lol";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();

            FileStream stream = new FileStream(path, FileMode.Open);

            TopScoreTracker topScoreTracker = formatter.Deserialize(stream) as TopScoreTracker;

            stream.Close();

            return(topScoreTracker);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);

            return(null);
        }
    }