コード例 #1
0
    public void LoadTimes()
    {
        playerTimes = new PlayerTimes();

        if (PlayerPrefs.HasKey("fullGameTime"))
        {
            playerTimes.fullGameTime = PlayerPrefs.GetFloat("fullGameTime");
        }
        if (PlayerPrefs.HasKey("Level1"))
        {
            playerTimes.Level1 = PlayerPrefs.GetFloat("Level1");
        }
        if (PlayerPrefs.HasKey("Level2"))
        {
            playerTimes.Level2 = PlayerPrefs.GetFloat("Level2");
        }
        if (PlayerPrefs.HasKey("Level3"))
        {
            playerTimes.Level3 = PlayerPrefs.GetFloat("Level3");
        }
        if (PlayerPrefs.HasKey("Level4"))
        {
            playerTimes.Level4 = PlayerPrefs.GetFloat("Level4");
        }
        if (PlayerPrefs.HasKey("Level5"))
        {
            playerTimes.Level5 = PlayerPrefs.GetFloat("Level5");
        }
        if (PlayerPrefs.HasKey("Level6"))
        {
            playerTimes.Level6 = PlayerPrefs.GetFloat("Level6");
        }
        if (PlayerPrefs.HasKey("Level7"))
        {
            playerTimes.Level7 = PlayerPrefs.GetFloat("Level7");
        }
        if (PlayerPrefs.HasKey("Level8"))
        {
            playerTimes.Level8 = PlayerPrefs.GetFloat("Level8");
        }
        if (PlayerPrefs.HasKey("Level9"))
        {
            playerTimes.Level9 = PlayerPrefs.GetFloat("Level9");
        }
        if (PlayerPrefs.HasKey("Level10"))
        {
            playerTimes.Level10 = PlayerPrefs.GetFloat("Level10");
        }

        LoadSoundPrefs();
    }
コード例 #2
0
    //Saves the player's high scores
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/PlayerTimes.dat");

        PlayerTimes data = new PlayerTimes();

        data.zone1Levels = allZone1Levels;
        data.zone2Levels = allZone2Levels;
        data.zone3Levels = allZone3Levels;

        bf.Serialize(file, data);
        file.Close();
    }
コード例 #3
0
    //Loads the player's high scores
    public void LoadTimes()
    {
        if (File.Exists(Application.persistentDataPath + "/PlayerTimes.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/PlayerTimes.dat", FileMode.Open);

            PlayerTimes data = (PlayerTimes)bf.Deserialize(file);
            file.Close();

            data.zone1Levels = allZone1Levels;
            data.zone2Levels = allZone2Levels;
            data.zone3Levels = allZone3Levels;
        }
    }