// Load public void LoadData(CropsManagerData cropsManagerData) { // todo: call Initialise? PopulateCropsList(); SortedList <int, int> cropsCount = cropsManagerData.cropsCount; for (int i = 0; i < cropsCount.Count; i++) { currentCropIndex++; int amount = cropsCount.Values[i]; InstantiateCropItemBar(CROPS_LIST[i], amount); } }
public void Save() { if (dontSave) { return; } DateTime lastSaveTime = DateTime.UtcNow; CropsManagerData cropsManagerData = cropsManager.SaveData(); CoinManagerData coinManagerData = coinManager.SaveData(); AllSaveData allSaveData = new AllSaveData(cropsManagerData, coinManagerData, lastSaveTime); BinaryFormatter bf = new BinaryFormatter(); //Application.persistentDataPath is a string, so if you wanted you can put that into debug.log if you want to know where save games are located FileStream file = File.Create(saveFilePath); //you can call it anything you want bf.Serialize(file, allSaveData); file.Close(); }
public AllSaveData(CropsManagerData cropsManagerData, CoinManagerData coinManagerData, DateTime lastSaveTime) { this.cropsManagerData = cropsManagerData; this.coinManagerData = coinManagerData; this.lastSaveTime = lastSaveTime; }