Exemplo n.º 1
0

        
        /// <summary>
        /// Writes the object.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="type">Type.</param>
        protected virtual void WriteObject(object value, Type type)
        {
            if (value is ISavable)
            {
                m_Writer.Write("{");
                m_IsFirstProperty = true;
                ISavable savable = value as ISavable;
                savable.OnWrite(this);
                m_Writer.Write("}");
            }
            else if (SaveGameTypeManager.HasType(type))
            {
                m_Writer.Write("{");
                m_IsFirstProperty = true;
                SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                saveGameType.Write(value, this);
                m_Writer.Write("}");
            }
#if !UNITY_WSA || !UNITY_WINRT
            else if (value is ISerializable)
            {
                SerializationInfo info         = new SerializationInfo(type, new FormatterConverter());
                ISerializable     serializable = value as ISerializable;
                serializable.GetObjectData(info, new StreamingContext(StreamingContextStates.All));
                WriteSerializationInfo(info);
            }
#endif
            else
            {
                WriteSavableMembers(value, type);
            }
        }
        /// <summary>
        /// Writes the object.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="type">Type.</param>
        protected virtual void WriteObject(object value, Type type)
        {
            if (value is ISavable)
            {
                ISavable savable = value as ISavable;
                savable.OnWrite(this);
            }
            else if (SaveGameTypeManager.HasType(type))
            {
                m_Writer.BaseStream.WriteByte(BinaryFormatter.SaveGameTypeStart);
                long position = m_Writer.BaseStream.Position;
                m_Writer.Write(0L);
                SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                saveGameType.Write(value, this);
                long lastPosition = m_Writer.BaseStream.Position;
                m_Writer.BaseStream.Position = position;
                m_Writer.Write(lastPosition);
                m_Writer.BaseStream.Position = lastPosition;
                m_Writer.BaseStream.WriteByte(BinaryFormatter.SaveGameTypeEnd);
            }
#if !UNITY_WSA || !UNITY_WINRT
            else if (value is ISerializable)
            {
                SerializationInfo info         = new SerializationInfo(type, new FormatterConverter());
                ISerializable     serializable = value as ISerializable;
                serializable.GetObjectData(info, new StreamingContext(StreamingContextStates.All));
                WriteSerializationInfo(info);
            }
#endif
            else
            {
                WriteSavableMembers(value, type);
            }
        }
Exemplo n.º 4
0
        public virtual void UpdateCurrentTypes()
        {
            Dictionary <string, MonoScript> scripts = new Dictionary <string, MonoScript>();

            string[] assetPaths = AssetDatabase.GetAllAssetPaths();
            foreach (string assetPath in assetPaths)
            {
                if (assetPath.EndsWith(".cs"))
                {
                    MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript>(assetPath);
                    Type       type   = script.GetClass();
                    if (typeof(SaveGameType).IsAssignableFrom(type))
                    {
                        scripts.Add(assetPath, script);
                    }
                }
            }
            foreach (var script in scripts)
            {
                Type scriptType = script.Value.GetClass();
                if (scriptType.IsAbstract)
                {
                    continue;
                }
                string       folderPath   = Path.GetDirectoryName(script.Key);
                SaveGameType saveGameType = (SaveGameType)Activator.CreateInstance(scriptType);
                CreateType(folderPath, saveGameType.AssociatedType);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a SaveGameInfo from parameters
        /// </summary>
        public SaveGameInfo(string niceName, string fileName, SaveGameType type, DateTime date)
        {
            NiceName = niceName;
            FileName = fileName;
            Type     = type;
            Date     = date;

            ImageData    = null;
            Location     = null;
            CampaignHash = null;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a SaveGameInfo from a file via FileInfo object
        /// </summary>
        public SaveGameInfo(FileInfo fileInfo)
        {
            SaveGameType type     = SaveGameType.Manual;
            string       niceName = Path.GetFileNameWithoutExtension(fileInfo.Name);

            if (niceName.Contains("_"))
            {
                //split nicename
                string[] splitName = niceName.Split('_');
                if (splitName.Length >= 2)
                {
                    niceName = niceName.Substring(niceName.IndexOf('_') + 1);
                    if (splitName[0] == "q")
                    {
                        niceName = $"{Sub.Replace("Quicksave", "IGUI_SAVE")}";
                        type     = SaveGameType.Quick;
                    }
                    else if (splitName[0] == "a")
                    {
                        niceName = $"{Sub.Replace("Autosave", "IGUI_SAVE")} {(splitName.Length > 2 ? splitName[2] : "?")}";
                        type     = SaveGameType.Auto;
                    }
                    else if (splitName[0] == "m")
                    {
                        type = SaveGameType.Manual;
                    }
                    else
                    {
                        niceName = Path.GetFileNameWithoutExtension(fileInfo.Name); //undo our oopsie if it turns out someone is trolling with prefixes
                    }
                }
            }

            NiceName = niceName;
            FileName = fileInfo.Name;
            Type     = type;
            Date     = fileInfo.CreationTime;

            ImageData    = null;
            Location     = null;
            CampaignHash = null;
        }
Exemplo n.º 7
0
    public static bool TryParseFilename(string path, out SaveGameType type, out int slotNumber)
    {
        type       = default;
        slotNumber = -1;

        var basename = Path.GetFileNameWithoutExtension(path);

        if (basename == "SlotQwik")
        {
            type = SaveGameType.QuickSave;
        }
        else if (basename == "SlotAuto")
        {
            type = SaveGameType.AutoSave;
        }
        else if (basename.StartsWith("slot"))
        {
            type = SaveGameType.Normal;
            var slotNumberStr = basename.Substring(4, 4);
            if (!int.TryParse(slotNumberStr, out slotNumber))
            {
                return(false);
            }
        }
        else if (basename.StartsWith("iron"))
        {
            type = SaveGameType.IronMan;
            var slotNumberStr = basename.Substring(4, 4);
            if (!int.TryParse(slotNumberStr, out slotNumber))
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 8
0
        /// <summary>
        /// Read the specified type.
        /// </summary>
        /// <param name="type">Type.</param>
        public override object Read(Type type)
        {
            Type   nullableType = null;
            object result       = null;

            if (type == null || string.IsNullOrEmpty(m_Json))
            {
                result = null;
            }
            else if (m_Json[m_Position] == 'n' && PeekString() == "null")
            {
                ReadString();
                result = null;
            }
            else
            {
                if (Nullable.GetUnderlyingType(type) != null)
                {
                    nullableType = type;
                    type         = Nullable.GetUnderlyingType(type);
                }
                bool isEnum         = false;
                bool isSerializable = false;
                bool isGeneric      = false;
#if (UNITY_WSA || UNITY_WINRT) && !UNITY_EDITOR
                TypeInfo info = type.GetTypeInfo();
                isEnum         = info.IsEnum;
                isSerializable = info.IsSerializable;
                isGeneric      = info.IsGenericType;
#else
                isEnum         = type.IsEnum;
                isSerializable = type.IsSerializable;
                isGeneric      = type.IsGenericType;
#endif
                if (type == typeof(UnityEngine.GameObject))
                {
                    // Skip object start
                    m_Position++;

                    m_IsFirstProperty = true;
                    int    layer    = 0;
                    bool   isStatic = false;
                    string tag      = "";
                    string name     = "";
                    UnityEngine.HideFlags hideFlags = UnityEngine.HideFlags.None;
                    foreach (string property in Properties)
                    {
                        switch (property)
                        {
                        case "layer":
                            layer = ReadProperty <int>();
                            break;

                        case "isStatic":
                            isStatic = ReadProperty <bool>();
                            break;

                        case "tag":
                            tag = ReadProperty <string>();
                            break;

                        case "name":
                            name = ReadProperty <string>();
                            break;

                        case "hideFlags":
                            hideFlags = ReadProperty <UnityEngine.HideFlags>();
                            break;
                        }
                    }
                    UnityEngine.GameObject gameObject = new UnityEngine.GameObject(name);
                    gameObject.layer     = layer;
                    gameObject.isStatic  = isStatic;
                    gameObject.tag       = tag;
                    gameObject.name      = name;
                    gameObject.hideFlags = hideFlags;

                    // Skip comma
                    m_Position++;

                    ReadQoutedString();

                    // Skip colon and array start
                    m_Position += 2;

                    int  length  = GetArrayLength();
                    bool isFirst = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }

                        // Skip object start
                        m_Position++;

                        ReadQoutedString();

                        // Skip colon
                        m_Position++;

                        string typeFullName             = ReadQoutedString();
                        Type   componentType            = Type.GetType(typeFullName);
                        UnityEngine.Component component = gameObject.GetComponent(componentType);
                        if (componentType != typeof(UnityEngine.Transform) && componentType.BaseType != typeof(UnityEngine.Transform))
                        {
                            UnityEngine.Component newComponent = gameObject.AddComponent(componentType);
                            if (newComponent != null)
                            {
                                component = newComponent;
                            }
                        }

                        // Skip comma
                        m_Position++;

                        ReadQoutedString();

                        // Skip colon
                        m_Position++;

                        ReadInto(component);

                        // Skip object end
                        m_Position++;
                    }

                    // Skip comma and array end
                    m_Position += 2;

                    ReadQoutedString();

                    // Skip colon and array start
                    m_Position += 2;

                    length  = GetArrayLength();
                    isFirst = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        ReadChild(gameObject);
                    }

                    result = gameObject;

                    // Skip object end
                    m_Position++;
                }
                else if (type == typeof(string))
                {
                    result = ReadQoutedString().UnEscapeStringJson();
                }
                else if (isEnum)
                {
                    result = Enum.Parse(type, ReadQoutedString().UnEscapeStringJson());
                }
                else if (type == typeof(bool))
                {
                    result = bool.Parse(ReadString());
                }
                else if (type == typeof(short) || type == typeof(int) || type == typeof(long) ||
                         type == typeof(ushort) || type == typeof(uint) || type == typeof(ulong) ||
                         type == typeof(byte) || type == typeof(sbyte) || type == typeof(decimal) ||
                         type == typeof(double) || type == typeof(float))
                {
                    result = Convert.ChangeType(ReadString(), type);
                }
                else if (type.IsArray)
                {
                    // Skip array start
                    m_Position++;

                    Type  elementType = type.GetElementType();
                    int   length      = GetArrayLength();
                    Array array       = Array.CreateInstance(elementType, length);
                    bool  isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        array.SetValue(Read(elementType), i);
                    }
                    result = array;

                    // Skip array end
                    m_Position++;
                }
                else if (type == typeof(DictionaryEntry))
                {
                    // Skip object start
                    m_Position++;

                    DictionaryEntry entry     = new DictionaryEntry();
                    bool            isFirst   = true;
                    Type            keyType   = null;
                    Type            valueType = null;
                    for (int i = 0; i < 4; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        string property = ReadQoutedString();

                        // Skip colon
                        m_Position++;

                        if (property == "KeyType")
                        {
                            keyType = Type.GetType(ReadQoutedString());
                        }
                        else if (property == "Key")
                        {
                            entry.Key = Read(keyType);
                        }
                        else if (property == "ValueType")
                        {
                            valueType = Type.GetType(ReadQoutedString());
                        }
                        else if (property == "Value")
                        {
                            entry.Value = Read(valueType);
                        }
                    }
                    result = entry;

                    // Skip object end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(KeyValuePair <,>))
                {
                    // Skip object start
                    m_Position++;

                    Type[] genericArgs = type.GetGenericArguments();
                    object key         = null;
                    object value       = null;

                    string property = ReadQoutedString();

                    // Skip colon
                    m_Position++;

                    if (property == "Key")
                    {
                        key = Read(genericArgs[0]);
                    }
                    else
                    {
                        value = Read(genericArgs[1]);
                    }


                    // Skip comma
                    m_Position++;

                    property = ReadQoutedString();

                    // Skip colon
                    m_Position++;

                    if (property == "Key")
                    {
                        key = Read(genericArgs[0]);
                    }
                    else
                    {
                        value = Read(genericArgs[1]);
                    }
                    result = Activator.CreateInstance(type, key, value);

                    // Skip object end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(List <>))
                {
                    // Skip array start
                    m_Position++;

                    Type[] genericArgs = type.GetGenericArguments();
                    int    length      = GetArrayLength();
                    IList  list        = (IList)Activator.CreateInstance(type);
                    bool   isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        list.Add(Read(genericArgs[0]));
                    }
                    result = list;

                    // Skip array end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(LinkedList <>))
                {
                    // Skip array start
                    m_Position++;

                    Type[]     genericArgs = type.GetGenericArguments();
                    int        length      = GetArrayLength();
                    object     list        = Activator.CreateInstance(type);
                    MethodInfo addLast     = type.GetMethod("AddLast", genericArgs);
                    bool       isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        addLast.Invoke(list, new object[] { Read(genericArgs[0]) });
                    }
                    result = list;

                    // Skip array end
                    m_Position++;
                }
                else if (isGeneric && (type.GetGenericTypeDefinition() == typeof(Dictionary <,>) ||
                                       type.GetGenericTypeDefinition() == typeof(SortedDictionary <,>) ||
                                       type.GetGenericTypeDefinition() == typeof(SortedList <,>)))
                {
                    // Skip object start
                    m_Position++;

                    Type[]      genericArgs = type.GetGenericArguments();
                    int         length      = GetObjectLength();
                    bool        isFirst     = true;
                    IDictionary dictionary  = (IDictionary)Activator.CreateInstance(type);
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        object key = Read(genericArgs[0]);

                        // Skip colon
                        m_Position++;

                        object value = Read(genericArgs[1]);
                        dictionary.Add(key, value);
                    }
                    result = dictionary;

                    // Skip object end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(Stack <>))
                {
                    // Skip array start
                    m_Position++;

                    Type[]     genericArgs = type.GetGenericArguments();
                    int        length      = GetArrayLength();
                    object     stack       = Activator.CreateInstance(type);
                    MethodInfo push        = type.GetMethod("Push");
                    bool       isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        push.Invoke(stack, new object[] { Read(genericArgs[0]) });
                    }
                    result = stack;

                    // Skip array end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(Queue <>))
                {
                    // Skip array start
                    m_Position++;

                    Type[]     genericArgs = type.GetGenericArguments();
                    int        length      = GetArrayLength();
                    object     queue       = Activator.CreateInstance(type);
                    MethodInfo enqueue     = type.GetMethod("Enqueue");
                    bool       isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        enqueue.Invoke(queue, new object[] { Read(genericArgs[0]) });
                    }
                    result = queue;

                    // Skip array end
                    m_Position++;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(HashSet <>))
                {
                    // Skip array start
                    m_Position++;

                    Type[]     genericArgs = type.GetGenericArguments();
                    int        length      = GetArrayLength();
                    object     hashSet     = Activator.CreateInstance(type);
                    MethodInfo addMethod   = type.GetMethod("Add");
                    bool       isFirst     = true;
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        addMethod.Invoke(hashSet, new object[] { Read(genericArgs[0]) });
                    }
                    result = hashSet;

                    // Skip array end
                    m_Position++;
                }
                else if (type == typeof(Hashtable))
                {
                    // Skip array start
                    m_Position++;

                    bool      isFirst   = true;
                    Hashtable hashtable = new Hashtable();
                    int       length    = GetArrayLength();
                    for (int i = 0; i < length; i++)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            // Skip comma
                            m_Position++;
                        }
                        DictionaryEntry entry = Read <DictionaryEntry>();
                        hashtable.Add(entry.Key, entry.Value);
                    }
                    result = hashtable;

                    // Skip array end
                    m_Position++;
                }
                else if (SaveGameTypeManager.HasType(type))
                {
                    // Skip object start
                    m_Position++;

                    m_IsFirstProperty = true;
                    SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                    result = saveGameType.Read(this);

                    // Skip object end
                    m_Position++;
                }
                else
                {
                    result = ReadObject(type);
                }
            }
#if !(UNITY_WSA || UNITY_WINRT) || UNITY_EDITOR
            if (result is IDeserializationCallback)
            {
                (result as IDeserializationCallback).OnDeserialization(this);
            }
#endif
            if (nullableType != null)
            {
                Type genericType = type.GetNullableType();
                result = Activator.CreateInstance(genericType, result);
            }
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Reads the data into the value.
        /// </summary>
        /// <param name="value">Value.</param>
        public override void ReadInto(object value)
        {
            if (value == null || string.IsNullOrEmpty(m_Json))
            {
                return;
            }
            else if (m_Json[m_Position] == 'n' && PeekString() == "null")
            {
                ReadString();
                return;
            }
            Type type      = value.GetType();
            bool isGeneric = false;

#if (UNITY_WSA || UNITY_WINRT) && !UNITY_EDITOR
            TypeInfo info = type.GetTypeInfo();
            isGeneric = info.IsGenericType;
#else
            isGeneric = type.IsGenericType;
#endif
            if (type == typeof(UnityEngine.GameObject))
            {
                // Skip object start
                m_Position++;

                m_IsFirstProperty = true;
                int    layer    = 0;
                bool   isStatic = false;
                string tag      = "";
                string name     = "";
                UnityEngine.HideFlags hideFlags = UnityEngine.HideFlags.None;
                foreach (string property in Properties)
                {
                    switch (property)
                    {
                    case "layer":
                        layer = ReadProperty <int>();
                        break;

                    case "isStatic":
                        isStatic = ReadProperty <bool>();
                        break;

                    case "tag":
                        tag = ReadProperty <string>();
                        break;

                    case "name":
                        name = ReadProperty <string>();
                        break;

                    case "hideFlags":
                        hideFlags = ReadProperty <UnityEngine.HideFlags>();
                        break;
                    }
                }
                UnityEngine.GameObject gameObject = value as UnityEngine.GameObject;
                gameObject.layer     = layer;
                gameObject.isStatic  = isStatic;
                gameObject.tag       = tag;
                gameObject.name      = name;
                gameObject.hideFlags = hideFlags;

                // Skip comma
                m_Position++;

                ReadQoutedString();

                // Skip colon and array start
                m_Position += 2;

                int  length  = GetArrayLength();
                bool isFirst = true;
                for (int i = 0; i < length; i++)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        // Skip comma
                        m_Position++;
                    }

                    // Skip object start
                    m_Position++;

                    ReadQoutedString();

                    // Skip colon
                    m_Position++;

                    string typeFullName             = ReadQoutedString();
                    Type   componentType            = Type.GetType(typeFullName);
                    UnityEngine.Component component = gameObject.GetComponent(componentType);
                    if (component == null)
                    {
                        component = gameObject.AddComponent(componentType);
                    }

                    // Skip comma
                    m_Position++;

                    ReadQoutedString();

                    // Skip colon
                    m_Position++;

                    ReadInto(component);

                    // Skip object end
                    m_Position++;
                }

                // Skip comma and array end
                m_Position += 2;

                ReadQoutedString();

                // Skip colon and array start
                m_Position += 2;

                length  = GetArrayLength();
                isFirst = true;
                for (int i = 0; i < length; i++)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        // Skip comma
                        m_Position++;
                    }
                    if (gameObject.transform.childCount > i)
                    {
                        UnityEngine.Transform childTransform = gameObject.transform.GetChild(i);
                        ReadInto <UnityEngine.GameObject>(childTransform.gameObject);
                    }
                    else
                    {
                        ReadChild(gameObject);
                    }
                }

                // Skip object end
                m_Position++;
            }
            else if (type.IsArray)
            {
                // Skip array start
                m_Position++;

                Type  elementType = type.GetElementType();
                int   length      = GetArrayLength();
                Array array       = value as Array;
                if (array.Length < length)
                {
                    array = Array.CreateInstance(elementType, length);
                }
                bool isFirst = true;
                for (int i = 0; i < array.Length; i++)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        // Skip comma
                        m_Position++;
                    }
                    object arrayValue = array.GetValue(i);
                    if (arrayValue == null)
                    {
                        array.SetValue(Read(elementType), i);
                    }
                    else
                    {
                        ReadInto(array.GetValue(i));
                    }
                }

                // Skip array end
                m_Position++;
            }
            else if (isGeneric && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                // Skip array start
                m_Position++;

                Type[] genericArgs = type.GetGenericArguments();
                int    length      = GetArrayLength();
                IList  list        = value as IList;
                bool   isFirst     = true;
                for (int i = 0; i < length; i++)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        // Skip comma
                        m_Position++;
                    }
                    if (list.Count > i && list[i] != null)
                    {
                        ReadInto(list[i]);
                    }
                    else
                    {
                        list.Add(Read(genericArgs[0]));
                    }
                }

                // Skip array end
                m_Position++;
            }
            else if (value is ICollection && value is IEnumerable)
            {
                // Skip array start
                m_Position++;

                IEnumerable e       = value as IEnumerable;
                bool        isFirst = true;
                foreach (object subValue in e)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        // Skip comma
                        m_Position++;
                    }
                    ReadInto(subValue);
                }

                // Skip array end
                m_Position++;
            }
            else if (SaveGameTypeManager.HasType(type))
            {
                // Skip object start
                m_Position++;

                m_IsFirstProperty = true;
                SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                saveGameType.ReadInto(value, this);

                // Skip object end
                m_Position++;
            }
            else
            {
                ReadObject(type, value);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Reads the data into the value.
        /// </summary>
        /// <param name="value">Value.</param>
        public virtual void ReadInto(object value)
        {
            if (value == null || !m_Reader.ReadBoolean())
            {
                return;
            }
            Type type      = value.GetType();
            bool isGeneric = false;

#if (UNITY_WSA || UNITY_WINRT) && !UNITY_EDITOR
            TypeInfo info = type.GetTypeInfo();
            isGeneric = info.IsGenericType;
#else
            isGeneric = type.IsGenericType;
#endif
            if (type == typeof(UnityEngine.GameObject))
            {
                // Skip save game type start
                m_Reader.ReadByte();
                m_Reader.ReadInt64();

                int    layer    = ReadProperty <int>();
                bool   isStatic = ReadProperty <bool>();
                string tag      = ReadProperty <string>();
                string name     = ReadProperty <string>();
                UnityEngine.HideFlags hideFlags = ReadProperty <UnityEngine.HideFlags>();

                // Skip save game type end
                m_Reader.ReadByte();

                UnityEngine.GameObject gameObject = value as UnityEngine.GameObject;
                gameObject.layer     = layer;
                gameObject.isStatic  = isStatic;
                gameObject.tag       = tag;
                gameObject.name      = name;
                gameObject.hideFlags = hideFlags;

                m_Reader.ReadString();
                int count = m_Reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    string typeName                 = m_Reader.ReadString();
                    Type   componentType            = Type.GetType(typeName);
                    UnityEngine.Component component = gameObject.GetComponent(componentType);
                    if (component == null)
                    {
                        component = gameObject.AddComponent(componentType);
                    }
                    ReadInto(component);
                }

                m_Reader.ReadString();
                count = m_Reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    if (gameObject.transform.childCount > i)
                    {
                        UnityEngine.Transform childTransform = gameObject.transform.GetChild(i);
                        ReadInto <UnityEngine.GameObject>(childTransform.gameObject);
                    }
                    else
                    {
                        ReadChild(gameObject);
                    }
                }
            }
            else if (type.IsArray)
            {
                Type  elementType = type.GetElementType();
                int   rank        = m_Reader.ReadInt32();
                int[] lengths     = new int[rank];
                for (int i = 0; i < rank; i++)
                {
                    lengths[i] = m_Reader.ReadInt32();
                }
                Array array   = Array.CreateInstance(elementType, lengths);
                int[] indices = new int[array.Rank];
                for (int i = 0; i < array.Rank; i++)
                {
                    indices[i] = array.GetLowerBound(i);
                }
                indices[array.Rank - 1]--;
                bool complete = false;
                while (!complete)
                {
                    indices[array.Rank - 1]++;
                    for (int i = array.Rank - 1; i >= 0; i--)
                    {
                        if (indices[i] > array.GetUpperBound(i))
                        {
                            if (i == 0)
                            {
                                complete = true;
                                break;
                            }
                            for (int j = i; j < array.Rank; j++)
                            {
                                indices[j] = array.GetLowerBound(j);
                            }
                            indices[i - 1]++;
                        }
                    }
                    if (!complete)
                    {
                        object arrayValue = array.GetValue(indices);
                        if (arrayValue == null)
                        {
                            array.SetValue(Read(elementType), indices);
                        }
                        else
                        {
                            ReadInto(array.GetValue(indices));
                        }
                    }
                }
            }
            else if (isGeneric && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                Type[] genericArgs = type.GetGenericArguments();
                IList  list        = value as IList;
                int    length      = m_Reader.ReadInt32();
                for (int i = 0; i < length; i++)
                {
                    if (list.Count > i && list[i] != null)
                    {
                        ReadInto(list[i]);
                    }
                    else
                    {
                        list.Add(Read(genericArgs[0]));
                    }
                }
            }
            else if (value is ICollection && value is IEnumerable)
            {
                m_Reader.ReadInt32();
                IEnumerable e = value as IEnumerable;
                foreach (object subValue in e)
                {
                    ReadInto(subValue);
                }
            }
            else if (SaveGameTypeManager.HasType(type))
            {
                // Skip save game type start
                m_Reader.ReadByte();
                m_Reader.ReadInt64();

                SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                saveGameType.ReadInto(value, this);

                // Skip save game type End
                m_Reader.ReadByte();
            }
            else
            {
                ReadIntoObject(type, value);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Read the specified type.
        /// </summary>
        /// <param name="type">Type.</param>
        public virtual object Read(Type type)
        {
            Type   nullableType = null;
            object result       = null;

            if (type == null || !m_Reader.ReadBoolean())
            {
                result = null;
            }
            else
            {
                if (Nullable.GetUnderlyingType(type) != null)
                {
                    nullableType = type;
                    type         = Nullable.GetUnderlyingType(type);
                }
                bool isPrimitive    = false;
                bool isEnum         = false;
                bool isSerializable = false;
                bool isGeneric      = false;
#if (UNITY_WSA || UNITY_WINRT) && !UNITY_EDITOR
                TypeInfo info = type.GetTypeInfo();
                isPrimitive    = info.IsPrimitive;
                isEnum         = info.IsEnum;
                isSerializable = info.IsSerializable;
                isGeneric      = info.IsGenericType;
#else
                isPrimitive    = type.IsPrimitive;
                isEnum         = type.IsEnum;
                isSerializable = type.IsSerializable;
                isGeneric      = type.IsGenericType;
#endif
                if (type == typeof(UnityEngine.GameObject))
                {
                    // Skip save game type start
                    m_Reader.ReadByte();
                    m_Reader.ReadInt64();

                    int    layer    = ReadProperty <int>();
                    bool   isStatic = ReadProperty <bool>();
                    string tag      = ReadProperty <string>();
                    string name     = ReadProperty <string>();
                    UnityEngine.HideFlags hideFlags = ReadProperty <UnityEngine.HideFlags>();

                    // Skip save game type end
                    m_Reader.ReadByte();

                    UnityEngine.GameObject gameObject = new UnityEngine.GameObject(name)
                    {
                        layer     = layer,
                        isStatic  = isStatic,
                        tag       = tag,
                        hideFlags = hideFlags
                    };

                    m_Reader.ReadString();
                    int count = m_Reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        string typeName                 = m_Reader.ReadString();
                        Type   componentType            = Type.GetType(typeName);
                        UnityEngine.Component component = gameObject.GetComponent(componentType);
                        if (componentType != typeof(UnityEngine.Transform) && componentType.BaseType != typeof(UnityEngine.Transform))
                        {
                            UnityEngine.Component newComponent = gameObject.AddComponent(componentType);
                            if (newComponent != null)
                            {
                                component = newComponent;
                            }
                        }
                        ReadInto(component);
                    }

                    m_Reader.ReadString();
                    count = m_Reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        ReadChild(gameObject);
                    }
                    result = gameObject;
                }
                else if (isPrimitive || type == typeof(string) || type == typeof(decimal))
                {
                    if (type == typeof(string))
                    {
                        result = m_Reader.ReadString();
                    }
                    else if (type == typeof(decimal))
                    {
                        result = m_Reader.ReadDecimal();
                    }
                    else if (type == typeof(short))
                    {
                        result = m_Reader.ReadInt16();
                    }
                    else if (type == typeof(int))
                    {
                        result = m_Reader.ReadInt32();
                    }
                    else if (type == typeof(long))
                    {
                        result = m_Reader.ReadInt64();
                    }
                    else if (type == typeof(ushort))
                    {
                        result = m_Reader.ReadUInt16();
                    }
                    else if (type == typeof(uint))
                    {
                        result = m_Reader.ReadUInt32();
                    }
                    else if (type == typeof(ulong))
                    {
                        result = m_Reader.ReadUInt64();
                    }
                    else if (type == typeof(double))
                    {
                        result = m_Reader.ReadDouble();
                    }
                    else if (type == typeof(float))
                    {
                        result = m_Reader.ReadSingle();
                    }
                    else if (type == typeof(byte))
                    {
                        result = m_Reader.ReadByte();
                    }
                    else if (type == typeof(sbyte))
                    {
                        result = m_Reader.ReadSByte();
                    }
                    else if (type == typeof(char))
                    {
                        result = m_Reader.ReadChar();
                    }
                    else if (type == typeof(bool))
                    {
                        result = m_Reader.ReadBoolean();
                    }
                }
                else if (isEnum)
                {
                    result = Enum.Parse(type, m_Reader.ReadString());
                }
                else if (type == typeof(DateTime))
                {
                    result = DateTime.FromBinary(m_Reader.ReadInt64());
                }
                else if (type == typeof(TimeSpan))
                {
                    result = TimeSpan.Parse(m_Reader.ReadString());
                }
                else if (type.IsArray)
                {
                    Type  elementType = type.GetElementType();
                    int   rank        = m_Reader.ReadInt32();
                    int[] lengths     = new int[rank];
                    for (int i = 0; i < rank; i++)
                    {
                        lengths[i] = m_Reader.ReadInt32();
                    }
                    Array array   = Array.CreateInstance(elementType, lengths);
                    int[] indices = new int[array.Rank];
                    for (int i = 0; i < array.Rank; i++)
                    {
                        indices[i] = array.GetLowerBound(i);
                    }
                    indices[array.Rank - 1]--;
                    bool complete = false;
                    while (!complete)
                    {
                        indices[array.Rank - 1]++;
                        for (int i = array.Rank - 1; i >= 0; i--)
                        {
                            if (indices[i] > array.GetUpperBound(i))
                            {
                                if (i == 0)
                                {
                                    complete = true;
                                    break;
                                }
                                for (int j = i; j < array.Rank; j++)
                                {
                                    indices[j] = array.GetLowerBound(j);
                                }
                                indices[i - 1]++;
                            }
                        }
                        if (!complete)
                        {
                            array.SetValue(Read(elementType), indices);
                        }
                    }
                    result = array;
                }
                else if (type == typeof(DictionaryEntry))
                {
                    DictionaryEntry entry   = new DictionaryEntry();
                    Type            keyType = Type.GetType(m_Reader.ReadString());
                    entry.Key = Read(keyType);
                    Type valueType = Type.GetType(m_Reader.ReadString());
                    entry.Value = Read(valueType);
                    result      = entry;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(KeyValuePair <,>))
                {
                    Type[] genericArgs = type.GetGenericArguments();
                    result = Activator.CreateInstance(type, Read(genericArgs[0]), Read(genericArgs[1]));
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(List <>))
                {
                    Type[] genericArgs = type.GetGenericArguments();
                    IList  list        = (IList)Activator.CreateInstance(type);
                    int    length      = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        list.Add(Read(genericArgs[0]));
                    }
                    result = list;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(LinkedList <>))
                {
                    Type[]     genericArgs = type.GetGenericArguments();
                    object     linkedList  = Activator.CreateInstance(type);
                    MethodInfo addLast     = type.GetMethod("AddLast", genericArgs);
                    int        length      = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        addLast.Invoke(linkedList, new object[] { Read(genericArgs[0]) });
                    }
                    result = linkedList;
                }
                else if (isGeneric && (type.GetGenericTypeDefinition() == typeof(Dictionary <,>) ||
                                       type.GetGenericTypeDefinition() == typeof(SortedDictionary <,>) ||
                                       type.GetGenericTypeDefinition() == typeof(SortedList <,>)))
                {
                    Type[]       genericArgs      = type.GetGenericArguments();
                    IDictionary  dictionary       = (IDictionary)Activator.CreateInstance(type);
                    int          length           = m_Reader.ReadInt32();
                    Type         keyValuePairType = typeof(KeyValuePair <,>).MakeGenericType(genericArgs);
                    PropertyInfo keyProperty      = keyValuePairType.GetProperty("Key", TypeUtils.SavableBindingFlags);
                    PropertyInfo valueProperty    = keyValuePairType.GetProperty("Value", TypeUtils.SavableBindingFlags);
                    for (int i = 0; i < length; i++)
                    {
                        object keyValuePair = Read(keyValuePairType);
                        dictionary.Add(keyProperty.GetValue(keyValuePair, null), valueProperty.GetValue(keyValuePair, null));
                    }
                    result = dictionary;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(Stack <>))
                {
                    Type[]     genericArgs = type.GetGenericArguments();
                    object     stack       = Activator.CreateInstance(type);
                    MethodInfo push        = type.GetMethod("Push");
                    int        length      = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        push.Invoke(stack, new object[] { Read(genericArgs[0]) });
                    }
                    result = stack;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(Queue <>))
                {
                    Type[]     genericArgs = type.GetGenericArguments();
                    object     queue       = Activator.CreateInstance(type);
                    MethodInfo enqueue     = type.GetMethod("Enqueue");
                    int        length      = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        enqueue.Invoke(queue, new object[] { Read(genericArgs[0]) });
                    }
                    result = queue;
                }
                else if (isGeneric && type.GetGenericTypeDefinition() == typeof(HashSet <>))
                {
                    Type[]     genericArgs = type.GetGenericArguments();
                    object     hashSet     = Activator.CreateInstance(type);
                    MethodInfo addMethod   = type.GetMethod("Add");
                    int        length      = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        addMethod.Invoke(hashSet, new object[] { Read(genericArgs[0]) });
                    }
                    result = hashSet;
                }
                else if (type == typeof(Hashtable))
                {
                    Hashtable hashtable = new Hashtable();
                    int       length    = m_Reader.ReadInt32();
                    for (int i = 0; i < length; i++)
                    {
                        DictionaryEntry entry = Read <DictionaryEntry>();
                        hashtable.Add(entry.Key, entry.Value);
                    }
                    result = hashtable;
                }
                else if (SaveGameTypeManager.HasType(type))
                {
                    // Skip save game type start
                    m_Reader.ReadByte();
                    m_Reader.ReadInt64();

                    SaveGameType saveGameType = SaveGameTypeManager.GetType(type);
                    result = saveGameType.Read(this);

                    // Skip save game type end
                    m_Reader.ReadByte();
                }
                else
                {
                    result = ReadObject(type);
                }
            }
#if !(UNITY_WSA || UNITY_WINRT) || UNITY_EDITOR
            if (result is IDeserializationCallback)
            {
                (result as IDeserializationCallback).OnDeserialization(this);
            }
#endif
            if (nullableType != null)
            {
                Type genericType = type.GetNullableType();
                result = Activator.CreateInstance(genericType, result);
            }
            return(result);
        }
Exemplo n.º 12
0
    public void LoadData()
    {
        ArrayList data = XMLHandler.LoadXML(dir+filename);

        int langs = DataHolder.LanguageCount;
        this.saveText = new string[langs];
        this.loadText = new string[langs];
        this.saveYesText = new string[langs];
        this.saveNoText = new string[langs];
        this.saveQuestionText = new string[langs];
        this.loadQuestionText = new string[langs];
        this.fileInfoLayout = new string[langs];
        this.emptyInfoLayout = new string[langs];
        this.spSaveText = new string[langs];
        this.spLoadText = new string[langs];
        this.spCancelText = new string[langs];
        this.autoFileName = new string[langs];
        this.autoSaveMessage = new string[langs];

        for(int i=0; i<langs; i++)
        {
            this.saveText[i] = "Select save file";
            this.loadText[i] = "Select load file";
            this.saveYesText[i] = "Yes";
            this.saveNoText[i] = "No";
            this.saveQuestionText[i] = "Save file %i?";
            this.loadQuestionText[i] = "Load file %i?";
            this.fileInfoLayout[i] = "File %i: %n Lvl. %l - %a, %t";
            this.emptyInfoLayout[i] = "File %i: empty";
            this.spSaveText[i] = "Save";
            this.spLoadText[i] = "Load";
            this.spCancelText[i] = "Cancel";
            this.autoFileName[i] = "AUTO";
            this.autoSaveMessage[i] = "Autosave";
        }

        if(data.Count > 0)
        {
            foreach(Hashtable entry in data)
            {
                if(entry[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.LOADSAVEHUDS)
                {
                    if(entry.ContainsKey(XMLHandler.NODES))
                    {
                        ArrayList subs = entry[XMLHandler.NODES] as ArrayList;
                        foreach(Hashtable val in subs)
                        {
                            if(val[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.LOADSAVEHUD)
                            {
                                if(val.ContainsKey("encryptdata")) encryptData = true;

                                if(val.ContainsKey("maxsavegames")) maxSaveGames = int.Parse((string)val["maxsavegames"]);
                                if(val.ContainsKey("savegametype"))
                                {
                                    saveGameType = (SaveGameType)System.Enum.Parse(
                                            typeof(SaveGameType), (string)val["savegametype"]);
                                }

                                if(val.ContainsKey("saveposition")) savePosition = int.Parse((string)val["saveposition"]);
                                if(val.ContainsKey("savequestionposition")) saveQuestionPosition = int.Parse((string)val["savequestionposition"]);
                                if(val.ContainsKey("fileicon")) fileIconName = val["fileicon"] as string;
                                if(val.ContainsKey("showchoice")) showChoice = bool.Parse((string)val["showchoice"]);
                                if(val.ContainsKey("showload")) showLoad = bool.Parse((string)val["showload"]);
                                if(val.ContainsKey("sppos")) spPosition = int.Parse((string)val["sppos"]);

                                if(val.ContainsKey("fadeout")) fadeOut = bool.Parse((string)val["fadeout"]);
                                if(val.ContainsKey("fadeouttime")) fadeOutTime = float.Parse((string)val["fadeouttime"]);
                                if(val.ContainsKey("fadeoutinterpolate")) fadeOutInterpolate = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["fadeoutinterpolate"]);
                                if(val.ContainsKey("fadein")) fadeIn = bool.Parse((string)val["fadein"]);
                                if(val.ContainsKey("fadeintime")) fadeInTime = float.Parse((string)val["fadeintime"]);
                                if(val.ContainsKey("fadeininterpolate")) fadeInInterpolate = (EaseType)System.Enum.Parse(typeof(EaseType), (string)val["fadeininterpolate"]);

                                if(val.ContainsKey("savestatistics")) this.saveStatistics = bool.Parse((string)val["savestatistics"]);
                                if(val.ContainsKey("savetime")) this.saveTime = bool.Parse((string)val["savetime"]);
                                if(val.ContainsKey("savestatistics")) this.saveStatistics = bool.Parse((string)val["savestatistics"]);
                                if(val.ContainsKey("saveparty")) this.saveParty = bool.Parse((string)val["saveparty"]);
                                if(val.ContainsKey("savepartyposition")) this.savePartyPosition = bool.Parse((string)val["savepartyposition"]);
                                if(val.ContainsKey("savespawnid")) this.saveSpawnID = int.Parse((string)val["savespawnid"]);
                                if(val.ContainsKey("saveitems")) this.saveItems = bool.Parse((string)val["saveitems"]);
                                if(val.ContainsKey("saveweapons")) this.saveWeapons = bool.Parse((string)val["saveweapons"]);
                                if(val.ContainsKey("savearmors")) this.saveArmors = bool.Parse((string)val["savearmors"]);
                                if(val.ContainsKey("saverecipes")) this.saveRecipes = bool.Parse((string)val["saverecipes"]);
                                if(val.ContainsKey("savemoney")) this.saveMoney = bool.Parse((string)val["savemoney"]);
                                if(val.ContainsKey("gamevarselector")) this.gameVariableSelector = (Selector)System.Enum.Parse(typeof(Selector), (string)val["gamevarselector"]);
                                if(val.ContainsKey("numbervarselector")) this.numberVariableSelector = (Selector)System.Enum.Parse(typeof(Selector), (string)val["numbervarselector"]);

                                if(val.ContainsKey("gamevariableslist"))
                                {
                                    this.gameVariableList = new string[int.Parse((string)val["gamevariableslist"])];
                                    for(int i=0; i<this.gameVariableList.Length; i++)
                                    {
                                        this.gameVariableList[i] = "";
                                    }
                                }
                                if(val.ContainsKey("numbervariablelist"))
                                {
                                    this.numberVariableList = new string[int.Parse((string)val["numbervariablelist"])];
                                    for(int i=0; i<this.numberVariableList.Length; i++)
                                    {
                                        this.numberVariableList[i] = "";
                                    }
                                }

                                if(val.ContainsKey("automessagepos"))
                                {
                                    this.showAutoSaveMessage = true;
                                    this.autoMessagePosition = int.Parse((string)val["automessagepos"]);
                                    this.autoVisibilityTime = float.Parse((string)val["autovisibilitytime"]);
                                }

                                ArrayList s = val[XMLHandler.NODES] as ArrayList;
                                foreach(Hashtable ht in s)
                                {
                                    if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SAVETEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.saveText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.LOADTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.loadText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SAVEYESTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.saveYesText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SAVENOTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.saveNoText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SAVEQUESTIONTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.saveQuestionText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.LOADQUESTIONTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.loadQuestionText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.FILEINFOLAYOUT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.fileInfoLayout);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.EMPTYINFOLAYOUT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.emptyInfoLayout);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SPSAVETEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.spSaveText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SPLOADTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.spLoadText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SPCANCELTEXT)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.spCancelText);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.SAVESCENENAME)
                                    {
                                        this.saveSceneName = ht[XMLHandler.CONTENT] as string;
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.GAMEVARLIST)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.gameVariableList);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.NUMBERVARLIST)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.numberVariableList);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.AUTOFILE)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.autoFileName);
                                    }
                                    else if(ht[XMLHandler.NODE_NAME] as string == LoadSaveHUDData.AUTOMESSAGE)
                                    {
                                        HashtableHelper.GetContentString(ht, ref this.autoSaveMessage);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 13
0