/// <summary> /// Gets stall space information from a save file. /// </summary> public static void GetProgressFromFile() { if (File.Exists(SaveLocation)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream file = File.Open(SaveLocation, FileMode.Open); // Get the content from the file and place in the data object. ProgressData data = (ProgressData)formatter.Deserialize(file); file.Close(); // Copy the data to the current stall space information. ProgressManager.StallSpaces = new StallSpaceInformation[MaxStallSpacesCount]; Array.Copy(data.StallSpaces, ProgressManager.StallSpaces, MaxStallSpacesCount); ProgressManager.Day = data.Day; // Get the money from the data. ProgressManager.Money = data.Money; // Get the unlocked customers. int[] tempCustomerUnlock = new int[data.CustomersUnlocked.Count]; data.CustomersUnlocked.CopyTo(tempCustomerUnlock); ProgressManager.CustomersUnlocked = new List <int>(tempCustomerUnlock); // Get the place size from the data. ProgressManager.PlaceSize = data.PlaceSize; // Get the tutorial mode. ProgressManager.TutorialMode = data.TutorialMode; } else { // Create new stall space information. ProgressManager.StallSpaces = new StallSpaceInformation[MaxStallSpacesCount]; // Only the first 3 stalls are activated and they are all empty. ProgressManager.StallSpaces[0] = new StallSpaceInformation() { StallSpaceNumber = 0, SpaceType = StallSpaceType.EmptyStall }; ProgressManager.StallSpaces[1] = new StallSpaceInformation() { StallSpaceNumber = 1, SpaceType = StallSpaceType.EmptyStall }; ProgressManager.StallSpaces[2] = new StallSpaceInformation() { StallSpaceNumber = 2, SpaceType = StallSpaceType.EmptyStall }; // Set the remaining stalls to be null. for (int i = 3; i < MaxStallSpacesCount; i++) { ProgressManager.StallSpaces[i] = null; } // Initialize day. ProgressManager.Day = 1; // Create initial money. ProgressManager.Money = 0; // Unlock initial customers. ProgressManager.CustomersUnlocked = new List <int>(); ProgressManager.CustomersUnlocked.Add(0); ProgressManager.CustomersUnlocked.Add(1); ProgressManager.PlaceSize = 0; // Tutorial is enabled. ProgressManager.TutorialMode = true; // Save the information to the save file. SaveProgressToFile(); } }