public void OverrideData(B_SaveFile file) { if (file == null) { Debug.Log("Save DOES NOT EXIST"); return; } FileNumber = file.FileNumber; FileName = file.Name; Character = file.Character; Debug.Log(file.MostRecentStage.SceneName); MostRecentStage.IsComplete = file.MostRecentStage.IsComplete; MostRecentStage.IsUnlocked = file.MostRecentStage.IsUnlocked; MostRecentStage.SceneName = file.MostRecentStage.SceneName; MostRecentStage.CollectedCollectible = file.MostRecentStage.CollectedCollectible; LoadWorldStats(file.World1, World1); LoadWorldStats(file.World2, World2); LoadWorldStats(file.World3, World3); LoadWorldStats(file.World4, World4); LoadWorldStats(file.World5, World5); }
public void SetFile(B_SaveFile file) { //If there is file data... Set it if (file != null) { SaveFileObj.OverrideData(file); Debug.Log("Most recent stage is... " + SaveFileObj.MostRecentStage.SceneName); StageMan.LoadStage(SaveFileObj.MostRecentStage); GetComponent <MenuManager>().ClearMenuStack(); } }
public static void SaveFile(D_SaveFile FileData) { Debug.Log("Saving File!"); BinaryFormatter formatter = new BinaryFormatter(); int fileIndex = FileData.FileNumber; string path = Application.persistentDataPath + "/save" + fileIndex.ToString() + ".rice"; FileStream stream = new FileStream(path, FileMode.Create); B_SaveFile data = new B_SaveFile(FileData); formatter.Serialize(stream, data); stream.Close(); }
//This is used to preview it in the UI public void PreviewSaveFile() { basic = SaveSystem.LoadFile(fileIndex); if (basic == null) { //So if the file does not exist when you select it Set the file to new GAme //So to show progress in a world it'll Previewer.SetEmptyFile(); } else { Previewer.SetProgressFile(basic); } //FIND ALL THE UI ELEMENTS THAT ARE NEEDED AND SET THE PREVIEW.... }
public void SetProgressFile(B_SaveFile data) { //CharacterSprite.sprite = CharacterSprites[data.Character]; FilePreview.SetActive(true); NewFile.SetActive(false); FileName.text = data.Name; SetWorldProgress(data.World1, WorldCompletionImage[0], WorldCompletionText[0], CollectibleImages[0], CollectibleText[0]); SetWorldProgress(data.World2, WorldCompletionImage[1], WorldCompletionText[1], CollectibleImages[1], CollectibleText[1]); SetWorldProgress(data.World3, WorldCompletionImage[2], WorldCompletionText[2], CollectibleImages[2], CollectibleText[2]); SetWorldProgress(data.World4, WorldCompletionImage[3], WorldCompletionText[3], CollectibleImages[3], CollectibleText[3]); SetWorldProgress(data.World5, WorldCompletionImage[4], WorldCompletionText[4], CollectibleImages[4], CollectibleText[4]); //SetWorldProgress(data.World6, WorldCompletionImage[5], WorldCompletionText[5], CollectibleImages[0], CollectibleText[0])); SetKeys(data.Secret); }
//This is used when you CLICK on the button. Then It will LOCK IN save file and start the game public void SelectFile() { if (Previewer.GetFileContext() == FileSelectContext.Copy) { Debug.Log("COPY FILE " + Previewer.GetCopyIndex()); if (Previewer.GetCopyIndex() == -1) { Debug.Log("COPY FILE Setting Index File"); Previewer.SetCopyIndex(fileIndex); } else if (Previewer.GetCopyIndex() >= 0) { //Copy the file Debug.Log("COPY FILE Set"); SaveSystem.CopyFile(Previewer.GetCopyIndex(), fileIndex); Previewer.SetCopyIndex(-1); //Then ask the previewer to re-load the file for previews. basic = SaveSystem.LoadFile(fileIndex); Previewer.SetProgressFile(basic); } } else if (Previewer.GetFileContext() == FileSelectContext.Delete) { SaveSystem.DeleteFile(fileIndex); basic = SaveSystem.LoadFile(fileIndex); Previewer.SetEmptyFile(); } else if (basic == null) { //If Our file is non existant then we need to make the keyboard popup to enter a file name. Previewer.ToggleKeyboard(true, fileIndex); } else { FindObjectOfType <GameManager>().SetFile(basic); } }
/* * public static D_SaveFile LoadFile(int fileIndex) * { * string path = Application.persistentDataPath + "/save" + fileIndex+ ".rice"; * if (File.Exists(path)) * { * FileStream stream = new FileStream(path, FileMode.Open); * BinaryFormatter formatter = new BinaryFormatter(); * B_SaveFile BinarySave = formatter.Deserialize(stream) as B_SaveFile; * stream.Close(); * * D_SaveFile save = new D_SaveFile(BinarySave); * return save; * } * else * { * Debug.LogWarning("File does not exist"); * return null; * } * } */ public static B_SaveFile LoadFile(int fileIndex) { Debug.Log("Loading File Data!"); string path = Application.persistentDataPath + "/save" + fileIndex + ".rice"; if (File.Exists(path)) { FileStream stream = new FileStream(path, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); B_SaveFile BinarySave = formatter.Deserialize(stream) as B_SaveFile; stream.Close(); //D_SaveFile save = new D_SaveFile(BinarySave); return(BinarySave); } else { Debug.LogWarning("File does not exist | " + fileIndex); //We Return null So we know to "make a new game" return(null); } }
private void Awake() { basic = SaveSystem.LoadFile(fileIndex); Previewer = GetComponentInParent <UI_FilePreviewer>(); }