Beispiel #1
0
    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;
    }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
    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));
    }