Пример #1
0
    /******************
    *
    *
    *   SCORE
    *
    *
    ******************/

    public void SaveData(int num)
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Create(Application.persistentDataPath + "/upScore.dat");
        UPScore         data            = new UPScore();

        //Save score to data.score
        data.score = num;

        binaryFormatter.Serialize(file, data);
        file.Close();
    }
Пример #2
0
    public void LoadData()
    {
        if (File.Exists(Application.persistentDataPath + "/upScore.dat"))
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream      file            = File.Open(Application.persistentDataPath + "/upScore.dat", FileMode.Open);
            UPScore         data            = (UPScore)binaryFormatter.Deserialize(file);
            file.Close();

            //Load data.score to score
            score = data.score;
            print("Welcome back!");
            print("Your current record is: " + score);
            showTutorial = false;
        }
        else
        {
            print("You have no records set.");

            //Sets score to 0
            score        = 0;
            showTutorial = true;
        }
    }