Ejemplo n.º 1
0
    public void Save(string saveName)
    {
        print("Saving game with name " + saveName);
        SerializableStore saveable = new SerializableStore
        {
            pollenBanked = this.pollenBanked,
            saveSpawn    = lastLampPos,
            buttonStates = new string[moths.Length]
        };

        for (int index = 0; index < moths.Length; index++)
        {
            saveable.buttonStates[index] = moths[index].Save();
        }

        string json = JsonUtility.ToJson(saveable);

        PlayerPrefs.SetString(saveName, json);
    }
Ejemplo n.º 2
0
    public void Load(string saveName)
    {
        print("Loading game with name " + saveName);
        string json = PlayerPrefs.GetString(saveName, "");

        if (json == "")
        {
            json = PlayerPrefs.GetString("defaultSave", "");
        }

        SerializableStore saved = JsonUtility.FromJson <SerializableStore>(json);

        for (int index = 0; index < moths.Length; index++)
        {
            moths[index].Load(saved.buttonStates[index]);
        }

        pollenBanked = saved.pollenBanked;
        lastLampPos  = saved.saveSpawn;
    }