Esempio n. 1
0
        public void LoadGame()
        {
            EconomyData eco = SaveSystem.LoadEconomy();

            totalMoney    = eco.money;
            totalExpense  = eco.expense;
            totalMonsters = eco.totalMonsters;
            SetupEconomy();
        }
Esempio n. 2
0
        public static void SaveEconomy(EconomyManager eco)
        {
            BinaryFormatter formatter = new BinaryFormatter();
            string          path      = Application.persistentDataPath + "/economy.save";
            FileStream      stream    = new FileStream(path, FileMode.Create);

            EconomyData data = new EconomyData(eco);

            formatter.Serialize(stream, data);
            stream.Close();
        }
Esempio n. 3
0
        public static EconomyData LoadEconomy()
        {
            string path = Application.persistentDataPath + "/economy.save";

            if (File.Exists(path))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                FileStream      stream    = new FileStream(path, FileMode.Open);

                EconomyData data = formatter.Deserialize(stream) as EconomyData;
                stream.Close();

                return(data);
            }
            else
            {
                Debug.LogError("No file found at " + path);
                return(null);
            }
        }