/// <summary> /// Find the inbox and put all the listing we have back into it using the ids we saved and a list of all the listing prefabs /// </summary> /// <param name="playerSaveData"></param> private void LoadMail(PlayerSaveData playerSaveData) { EmailInbox inbox = FindObjectOfType <EmailInbox>(); for (int i = 0; i < playerSaveData.mailListings.Count; i++) { if (playerSaveData.mailListings[i] <= _mailDictionary.Count) { inbox.LoadEmail(_mailDictionary[playerSaveData.mailListings[i] - 1].listing, playerSaveData.emailPosition[i], playerSaveData.mailStatus[i]); } } }
/// <summary> /// Reset the tab list. Then we fill the tab list again with all the saved tabs so that the tabs are visible again. /// </summary> /// <param name="playerSaveData"></param> private void LoadPrefabCases(PlayerSaveData playerSaveData) { List <float> idList = playerSaveData.tabList; BrowserManager bm = FindObjectOfType <BrowserManager>(); bm.ResetList(); for (int i = 0; i < _tabDictionary.Count; i++) { for (int j = 0; j < idList.Count; j++) { if (_tabDictionary[i].GetId().Equals(idList[j])) { bm.SetPrefab(_tabDictionary[i].prefab, playerSaveData.tabInfoList[j]); } } } }
/// <summary> /// Load all the saveData from the saveFile. /// </summary> /// <returns></returns> public static PlayerSaveData LoadPlayer() { string path = Application.persistentDataPath + "player.save"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); PlayerSaveData saveData = formatter.Deserialize(stream) as PlayerSaveData; stream.Close(); return(saveData); } else { Debug.Log("No save file found"); return(null); } }
/// <summary> /// Loads the player level /// </summary> /// <param name="playerSaveData"></param> private void LoadLevel(PlayerSaveData playerSaveData) { FindObjectOfType <MissionManager>().playerLevel = playerSaveData.playerLevel; }
/// <summary> /// Loads the status of the printed pages. /// </summary> /// <param name="playerSaveData"></param> private void LoadPrintStatus(PlayerSaveData playerSaveData) { FindObjectOfType <BrowserManager>().SetPrintStatus(playerSaveData.GetPrintStatus()); }
/// <summary> /// Loads all the created Listings /// </summary> /// <param name="playerSaveData"></param> private void LoadCreatedListings(PlayerSaveData playerSaveData) { MissionManager manager = FindObjectOfType <MissionManager>(); manager.LoadManagerState(playerSaveData.GetCreatedList()); }
/// <summary> /// It will check the mailDictionary for the position that was saved in the emailListing. The emailListing list /// stores the actual caseId for a case and because the list starts at 0 we need to do -1 because the first case is 1 /// </summary> /// <param name="playerSaveData"></param> private void LoadHelpFolders(PlayerSaveData playerSaveData) { Printer printer = FindObjectOfType <Printer>(); Dictionary <int, int> tempDict = new Dictionary <int, int>(); foreach (var id in playerSaveData.GetPrinted()) { string first = id.ToString().Split(',')[0]; int temp = (int)float.Parse(first); if (temp != 0) { EmailListing newListing = _mailDictionary[playerSaveData.mailListings[temp - 1] - 1].listing .GetComponent <EmailListing>(); foreach (var tabItem in _tabDictionary) { foreach (var mails in FindObjectOfType <EmailInbox>().GetEmails()) { if (tabItem.GetId().Equals(id)) { if (mails.caseName == newListing.caseName) { bool tempBool = false; foreach (var item in tempDict) { if (item.Key == temp) { foreach (var folder in FilingCabinet.Instance.caseFolders) { if (folder.caseNumber == item.Value) { printer.Print(tabItem.prefab.GetComponent <Tab>(), mails.caseNumber, true); tempBool = true; break; } } break; } } if (!tempBool) { var newFolder = FilingCabinet.Instance.CreateFolderLoad(); newFolder.LabelFolder(newListing.caseName, "Case " + mails.caseNumber, mails.caseNumber, mails.listingPosition); tempDict.Add(temp, mails.caseNumber); foreach (var currentSolved in playerSaveData.GetSolved()) { if (currentSolved.GetHasWon()) { string solvedString = currentSolved.GetId().ToString().Split(',')[0]; int solvedId = (int)float.Parse(solvedString); if (solvedId == temp) { newFolder.DisplayOutcome(currentSolved.GetOutcome(), true); } } } // initiate game printing printer.Print(tabItem.prefab.GetComponent <Tab>(), mails.caseNumber, true); break; } } } } } } } }