public void LoadFromSerializableSave(SerializableSave s) { this.slotNum = s.slotNum; this.gameFlags = s.gameFlags; this.persistentObjects = new Dictionary <string, SerializedPersistentObject>(); for (int i = 0; i < s.persistentObjectKeys.Count; i++) { this.persistentObjects[s.persistentObjectKeys[i]] = s.persistentObjectValues[i]; } this.sceneName = s.sceneName; this.playerPosition = new Vector2(s.xPos, s.yPos); this.unlocks.LoadFromSerializableUnlocks(s.unlocks); GlobalController.inventory.items.LoadFromSerializableInventoryList(s.playerItems); if (Application.isEditor && !loadSceneInEditor) { GlobalController.MovePlayerTo(playerPosition); } else { GlobalController.LoadSceneToPosition(sceneName, playerPosition); } GlobalController.pc.maxHP = s.maxHP; GlobalController.pc.maxEnergy = s.maxEnergy; GlobalController.pc.baseDamage = s.baseDamage; }
public void LoadNewGamePlus(SerializableSave s, int slotNum) { this.unlocks.LoadFromSerializableUnlocks(s.unlocks); GlobalController.pc.maxHP = s.maxHP; GlobalController.pc.maxEnergy = s.maxEnergy; GlobalController.pc.baseDamage = s.baseDamage; }
public bool HasSavedGame(int slot = 1) { try { SerializableSave s = LoadCharacter(GetSavePath(slot)); return(s != null); } catch (Exception) { // sinful, but it's an easy way to handle save format changes return(false); } }
public bool HasFinishedGame(int slot = 1) { if (!HasSavedGame()) { return(false); } string folderPath = GetFolderPath(); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string dataPath = GetSavePath(slot); SerializableSave s = LoadCharacter(dataPath); return(s.gameFlags.Contains(GameFlag.BeatGame)); }