Exemplo n.º 1
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            // Old data (without ads).
            BinaryFormatter bf      = new BinaryFormatter();
            FileStream      file    = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            GameData        oldData = (GameData)bf.Deserialize(file);
            file.Close();

            // Migrate to the new data.
            data           = new GameDataWithAds();
            data.levelData = oldData.levelData;
            data.showAds   = false;
            Save();
        }
        else if (File.Exists(Application.persistentDataPath + "/playerInfo2.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerInfo2.dat", FileMode.Open);
            data = (GameDataWithAds)bf.Deserialize(file);
            file.Close();
        }
        else
        {
            InitDataAndSave();
        }
    }
Exemplo n.º 2
0
    //Level hasn't completed has a score of -1
    void InitDataAndSave()
    {
        data           = new GameDataWithAds();
        data.levelData = new float[Galaxies, Levels];

        for (int i = 0; i < Galaxies; i++)
        {
            for (int j = 0; j < Levels; j++)
            {
                data.levelData[i, j] = -1f;
            }
        }

        data.showAds = true;
        Save();
    }