//Function called from the MainMenu scene to continue the most recent save public void ContinueGame() { //If the most recent save doesn't exist, we're trying to load settings that don't exist if (!PlayerPrefs.HasKey("MostRecentSave")) { Debug.Log("ContinueGame, MostRecentSave doesn't exist"); return; } else if (PlayerPrefs.GetString("MostRecentSave") == "") { Debug.Log("ContinueGame, MostRecentSave is empty"); return; } else if (!System.IO.Directory.Exists(Application.persistentDataPath + PlayerPrefs.GetString("MostRecentSave"))) { Debug.Log("ContinueGame, MostRecentSave folder directory doesn't exist"); return; } //Loading the folder name for the most recent save so we can "Continue" this.saveFolder = PlayerPrefs.GetString("MostRecentSave"); //Telling the map generator to load our existing level this.loadType = levelLoadType.LoadLevel; //Transitioning to the gameplay level this.GetComponent <GoToLevel>().LoadLevelByName(this.gameplayLevelName); }
//Function called from LoadSavePanel.cs to load a saved game public void LoadSaveFile(string saveFolder_) { //Making sure the given save folder exists if (!System.IO.Directory.Exists(Application.persistentDataPath + saveFolder_)) { return; } //Setting the most recent save to the given folder PlayerPrefs.SetString("MostRecentSave", saveFolder_); //Setting the save folder as our current save this.saveFolder = saveFolder_; //Telling the map generator to load our existing level this.loadType = levelLoadType.LoadLevel; //Transitioning to the gameplay level this.GetComponent <GoToLevel>().LoadLevelByName(this.gameplayLevelName); }
//Function called from the New Game screen in the main menu. Starts the process of creating a new map public void StartNewGame() { //Determining if new items will be available in this game based on the seed value if (this.GetComponent <RandomSeedGenerator>().seed == "") { this.allowNewUnlockables = true; } else { this.allowNewUnlockables = false; } //Making sure our save folder name is valid this.saveFolder = SaveLoadManager.globalReference.CheckFolderName(this.saveFolder); //Telling the map generator to create a new level instead of loading one from a save this.loadType = levelLoadType.GenerateNewLevel; //Saving the current save folder name so we know which game was played last. Used for "Continuing" PlayerPrefs.SetString("MostRecentSave", GameData.globalReference.saveFolder); //Transitioning to the gameplay level this.GetComponent <GoToLevel>().LoadLevelByName(this.gameplayLevelName); }