Exemple #1
0
        /**
         * <summary>De-serializes a RememberData class, either from XML or Binary, depending on the platform.</summary>
         * <param name = "dataString">The RememberData class, serialized as a string</param>
         * <returns>The de-serialized RememberData class</return>
         */
        public static T LoadScriptData <T> (string dataString) where T : RememberData
        {
            SaveMethod saveMethod = SaveSystem.GetSaveMethod();

            if (dataString.StartsWith(saveMethod.ToString()))
            {
                dataString = dataString.Remove(0, saveMethod.ToString().ToCharArray().Length);
            }

            if (saveMethod == SaveMethod.Binary)
            {
                return((T)Serializer.DeserializeRememberData <T> (dataString));
            }
            else
            {
                return(Serializer.DeserializeObject <T> (dataString));
            }
        }
Exemple #2
0
        /**
         * <summary>De-serializes a List of SingleLevelData object from a string, according to the game's SaveMethod.</summary>
         * <param name = "dataString">The object, serialized into a string</param>
         * <param name = "delimieter">If using Json, then this string is used to separate each SingleLevelData instance.</param>
         * <returns>The object, deserialized</returns>
         */
        public static List <SingleLevelData> DeserializeAllRoomData(string dataString, string delimiter = "|ROOMDELIMITER|")
        {
            if (SaveSystem.GetSaveMethod() == SaveMethod.Json)
            {
                // Can't serialize a list, so split by delimeter
                List <SingleLevelData> allLevelData = new List <SingleLevelData>();
                string[] stringSeparators           = new string[] { delimiter };
                string[] levelDataStrings           = dataString.Split(stringSeparators, StringSplitOptions.None);
                foreach (string levelDataString in levelDataStrings)
                {
                    SingleLevelData levelData = DeserializeObject <SingleLevelData> (levelDataString);
                    allLevelData.Add(levelData);
                }
                return(allLevelData);
            }

            return((List <SingleLevelData>)Serializer.DeserializeObject <List <SingleLevelData> > (dataString));
        }