//Saves game data at given save slot index public void SaveGame(int _saveSlotIndex) { if (_saveSlotIndex <= 0 || _saveSlotIndex > 8) //This game will have a maximum 8 (0 to 8) save slots hardcoded. 0 slot should be reserved for quicksave { Debug.LogError("[Error] Invalid save slot index! Slot number must be between from 1 to 8."); return; } loadedSaveData = new SaveData(); loadedSaveData.savefileHeader = "Marco Lives: " + loadedSaveData.livesAmount + "; Ammo: " + loadedSaveData.ammoAmount + "; Seeds: " + loadedSaveData.seedsCollected + "; Levels Unlocked: " + loadedSaveData.levelsUnlocked; loadedSaveData.gameVersion = this.gameVersion; loadedSaveData.playerLocationX = this.playerLocation.x; loadedSaveData.playerLocationY = this.playerLocation.y; loadedSaveData.playerLocationZ = this.playerLocation.z; loadedSaveData.playerOrientationX = this.playerOrientation.x; loadedSaveData.playerOrientationY = this.playerOrientation.y; loadedSaveData.playerOrientationZ = this.playerOrientation.z; loadedSaveData.livesAmount = this.livesAmount; loadedSaveData.ammoAmount = this.ammoAmount; loadedSaveData.seedsCollected = this.seedsCollected; loadedSaveData.aliensKilled = this.aliensKilled; loadedSaveData.currentLevel = this.currentLevel; //0 means not in a level loadedSaveData.levelsUnlocked = this.levelsUnlocked; SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + _saveSlotIndex + ".hamsave", loadedSaveData); }
//Saves given game data at given save slot index public void SaveGame(int _saveSlotIndex, SaveData _saveData) { if (_saveSlotIndex <= 0 || _saveSlotIndex > 8) //This game will have a maximum 8 save slots hardcoded. { Debug.LogError("[Error] Invalid save slot index! Slot number must be between from 1 to 8."); return; } _saveData.gameVersion = this.gameVersion; _saveData.savefileHeader = "Marco Lives: " + _saveData.livesAmount + "; Ammo: " + _saveData.ammoAmount + "; Seeds: " + _saveData.seedsCollected + "; Levels Unlocked: " + _saveData.levelsUnlocked; SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + _saveSlotIndex + ".hamsave", _saveData); }
private IEnumerator QuickSaveRoutine(float delay) { canActivateCheckpoint = false; if (saveManagerRef) { saveManagerRef.QuickSave(); } else { SaveData newData = new SaveData(); newData.gameVersion = "0.1"; SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/Hamstronaut0.hamsave", newData); } yield return(new WaitForSeconds(delay)); canActivateCheckpoint = true; }
public void QuickSave() { loadedSaveData = new SaveData(); loadedSaveData.savefileHeader = "(Quicksave) Marco Lives: " + loadedSaveData.livesAmount + "; Ammo: " + loadedSaveData.ammoAmount + "; Seeds: " + loadedSaveData.seedsCollected + "; Levels Unlocked: " + loadedSaveData.levelsUnlocked; loadedSaveData.gameVersion = this.gameVersion; loadedSaveData.playerLocationX = this.playerLocation.x; loadedSaveData.playerLocationY = this.playerLocation.y; loadedSaveData.playerLocationZ = this.playerLocation.z; loadedSaveData.playerOrientationX = this.playerOrientation.x; loadedSaveData.playerOrientationY = this.playerOrientation.y; loadedSaveData.playerOrientationZ = this.playerOrientation.z; loadedSaveData.livesAmount = this.livesAmount; loadedSaveData.ammoAmount = this.ammoAmount; loadedSaveData.seedsCollected = this.seedsCollected; loadedSaveData.aliensKilled = this.aliensKilled; loadedSaveData.currentLevel = this.currentLevel; //0 means not in a level loadedSaveData.levelsUnlocked = this.levelsUnlocked; SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + "0.hamsave", loadedSaveData); }