Пример #1
0
    static SaveGameManager()
    {
        LOCK         = false;
        mainFilePath = Application.dataPath + "/Warpaid.save";   // need to change to persistentDataPath when publicize
        filePath     = Application.dataPath + "/PlayerOne.save"; // need to change to persistentDataPath when publicize

#if DEBUG_VerboseConsoleLogging
        Debug.Log("SaveGameManager:Awake() – Path: " + filePath);
#endif

        saveFileList = new SaveFileList();
        saveFile     = new SaveFile();
    }
Пример #2
0
    public static void LoadMainData()
    {
        if (File.Exists(mainFilePath))
        {
            string dataAsJson = File.ReadAllText(mainFilePath);
#if DEBUG_VerboseConsoleLogging
            Debug.Log("SaveGameManager:LoadMainData() – File text is:\n" + dataAsJson);
#endif

            try
            {
                saveFileList = JsonUtility.FromJson <SaveFileList>(dataAsJson);
            }
            catch
            {
                Debug.LogWarning("SaveGameManager:LoadMainData() - Save was malformed.\n" + dataAsJson);
                return;
            }
#if DEBUG_VerboseConsoleLogging
            Debug.Log("SaveGameManager:LoadMainData() – Successfully loaded save file.");
#endif
            LOCK = true;
            // Load list of savefiles etc
            //saveFileList =

            LOCK = false;
        }
        else
        {
#if DEBUG_VerboseConsoleLogging
            Debug.LogWarning("SaveGameManager:LoadMainData() – Unable to find save file. "
                             + "This is NOT totally fine. Make it now!");
#endif
            LOCK = true;
            // Init achievements and everything if needed
            // Init list of savefiles etc
            //saveFileList =
            // sth just like this AchievementManager.ClearStepsAndAchievements();

            LOCK = false;
        }
    }
Пример #3
0
    public static void SaveMainData()
    {
        // Do not save when is LOCKed
        if (LOCK)
        {
            return;
        }

        // import data to saveFile
        saveFileList = Warpaid.GetSaveFileList();


        string jsonSaveFile = JsonUtility.ToJson(saveFileList, true);

        File.WriteAllText(mainFilePath, jsonSaveFile);
#if DEBUG_VerboseConsoleLogging
        Debug.Log("SaveGameManager:SaveMainData() – Path: " + mainFilePath);
        Debug.Log("SaveGameManager:SaveMainData() – JSON: " + jsonSaveFile);
#endif
    }