public void LoadGameFile(string gameFileName) { activeGameFileName = gameFileName; string filePath = FileManager.savPath + "savData/gameFiles/" + activeGameFileName + ".txt"; if (!System.IO.File.Exists(filePath)) { activeGameFile = new GAMEFILE(); } else { if (encryptGameFile) { activeGameFile = FileManager.LoadEncryptedJSON <GAMEFILE>(filePath, keys); } else { activeGameFile = FileManager.LoadJSON <GAMEFILE>(filePath); } } //Load the file data = FileManager.LoadFile(FileManager.savPath + "Resources/Story/" + activeGameFile.chapterName); activeChapterFile = activeGameFile.chapterName; cachedLastSpeaker = activeGameFile.cachedLastSpeaker; DialogueSystem.instance.Open(activeGameFile.currentTextSystemSpeakerNameText, activeGameFile.currentTextSystemDisplayText); //Load the layer images back into the scene if (activeGameFile.background != null) { BCFC.instance.background.SetTexture(activeGameFile.background); } if (activeGameFile.cinematic != null) { BCFC.instance.cinematic.SetTexture(activeGameFile.cinematic); } if (activeGameFile.foreground != null) { BCFC.instance.foreground.SetTexture(activeGameFile.foreground); } //start the music back up if (activeGameFile.music != null) { AudioManager.instance.PlaySong(activeGameFile.music); } if (handlingChapterFile != null) { StopCoroutine(handlingChapterFile); } handlingChapterFile = StartCoroutine(HandlingChapterFile()); chapterProgress = activeGameFile.chapterProgress; }
public void LoadFromSelectedSlot() { //we need to load the data from this slot to know what to do. GAMEFILE file = FileManager.LoadEncryptedJSON <GAMEFILE>(selectedFilePath, FileManager.keys); //save the name of the file that we will be loading in the visual novel. carries over to next scene. FileManager.SaveFile(FileManager.savPath + "savData/file", selectedGameFile); UnityEngine.SceneManagement.SceneManager.LoadScene("Novel"); gameObject.SetActive(false);//deactivate the panel after loading. }
public void LoadFilesOntoScreen(int page = 1) { currentSaveLoadPage = page; string directory = FileManager.savPath + "savData/gameFiles/" + page.ToString() + "/"; if (System.IO.Directory.Exists(directory)) { for (int i = 0; i < buttons.Count; i++) { BUTTON b = buttons[i]; string expectedFile = directory + (i + 1).ToString() + ".txt"; if (System.IO.File.Exists(expectedFile)) { GAMEFILE file = FileManager.LoadEncryptedJSON <GAMEFILE>(expectedFile, FileManager.keys); b.button.interactable = true; byte[] previewImageData = FileManager.LoadComposingBytes(directory + (i + 1).ToString() + ".png"); Texture2D previewImage = new Texture2D(2, 2); ImageConversion.LoadImage(previewImage, previewImageData); file.previewImage = previewImage; b.previewDisplay.texture = file.previewImage; //need to read date and time information from file. b.dateTimeText.text = page.ToString() + "\n" + file.modificationDate; } else { b.button.interactable = allowSavingFromThisScreen; b.previewDisplay.texture = Resources.Load <Texture2D>("Images/UI/EmptyGameFile"); b.dateTimeText.text = page.ToString() + "\n" + "empty file..."; } } } else { for (int i = 0; i < buttons.Count; i++) { BUTTON b = buttons[i]; b.button.interactable = allowSavingFromThisScreen; b.previewDisplay.texture = Resources.Load <Texture2D>("Images/UI/EmptyGameFile"); b.dateTimeText.text = page.ToString() + "\n" + "empty file..."; } } }
public void LoadGameFile(int gameFileIndex) { string filePath = FileManager.savPath + "Resources/gamefile/" + gameFileIndex.ToString() + ".txt"; if (!System.IO.File.Exists(filePath)) { ///this line is for saving file/game data FileManager.SaveJSON(filePath, new GAMEFILE()); } ///load saved game data GAMEFILE gameFile = FileManager.LoadJSON <GAMEFILE>(filePath); /// load the chapter file data = FileManager.LoadFile(FileManager.savPath + "Resources/Story/" + gameFile.chapterName); cacheLastSpeaker = gameFile.cachedLastSpeaker; chapterProgress = gameFile.chapterProgress; if (handlingChapterFile != null) { StopCoroutine(handlingChapterFile); } handlingChapterFile = StartCoroutine(HandlingChapterFile()); }
public void LoadGameFile(string gameFileName) { activeGameFileName = gameFileName; string filePath = FileManager.savPath + "savData/gameFiles/" + activeGameFileName + ".txt"; if (!System.IO.File.Exists(filePath)) { activeGameFile = new GAMEFILE();//don't save because we want a new one to start whenever we hit new game. any save is manual. } else { if (encryptGameFile) { activeGameFile = FileManager.LoadEncryptedJSON <GAMEFILE>(filePath, keys); } else { activeGameFile = FileManager.LoadJSON <GAMEFILE>(filePath); } } //Load the file. Anything in the Resources folder should be loaded by Resources only. TextAsset chapterAsset = Resources.Load <TextAsset>("Story/" + activeGameFile.chapterName); data = FileManager.ReadTextAsset(chapterAsset); activeChapterFile = activeGameFile.chapterName; cachedLastSpeaker = activeGameFile.cachedLastSpeaker; DialogueSystem.instance.Open(activeGameFile.currentTextSystemSpeakerNameText, activeGameFile.currentTextSystemDisplayText); //Load all characters back into the scene for (int i = 0; i < activeGameFile.charactersInScene.Count; i++) { GAMEFILE.CHARACTERDATA data = activeGameFile.charactersInScene[i]; Character character = CharacterManager.instance.CreateCharacter(data.characterName, data.enabled); character.displayName = data.displayName; character.canvasGroup.alpha = 1;//any saved character should start with an alpha of 1 since they already entered at one point in time and any character that should have an alpha of zero would already have been removed. character.SetBody(data.bodyExpression); character.SetExpression(data.facialExpression); if (data.facingLeft) { character.FaceLeft(); } else { character.FaceRight(); } character.SetPosition(data.position); } //Load the layer images back into the scene if (activeGameFile.background != null) { BCFC.instance.background.SetTexture(activeGameFile.background); } if (activeGameFile.cinematic != null) { BCFC.instance.cinematic.SetTexture(activeGameFile.cinematic); } if (activeGameFile.foreground != null) { BCFC.instance.foreground.SetTexture(activeGameFile.foreground); } //start the music back up if (activeGameFile.music != null) { AudioManager.instance.PlaySong(activeGameFile.music); } //start the ambiance back up if (activeGameFile.ambiance.Count > 0) { foreach (AudioClip clip in activeGameFile.ambiance) { AudioManager.instance.PlayAmbiance(clip); } } //load the temporary variables back CACHE.tempVals = activeGameFile.tempVals; if (handlingChapterFile != null) { StopCoroutine(handlingChapterFile); } handlingChapterFile = StartCoroutine(HandlingChapterFile()); chapterProgress = activeGameFile.chapterProgress; }