Esempio n. 1
0
        public static void readSaveData(ref SerializationInfo info, ref StreamingContext context)
        {
            SerializationInfoEnumerator infoEnum = info.GetEnumerator();
            Hashtable values = new Hashtable();

            while (infoEnum.MoveNext())
            {
                SerializationEntry val = infoEnum.Current;
                values.Add(val.Name, val.Value);
            }
            if (Main.saveVersionFromDisk >= 11)
            {
                foreach (Upgrade item in cashUpgradeList)
                {
                    if (values.Contains("upgrade_" + item.saveName) && (bool)values["upgrade_" + item.saveName])
                    {
                        item.applyUpgrade();
                    }
                }
                foreach (Upgrade item in renownUpgradeList)
                {
                    if (values.Contains("renown_upgrade_" + item.saveName) && (bool)values["renown_upgrade_" + item.saveName])
                    {
                        item.applyUpgrade();
                    }
                }
            }
            else if (Main.saveVersionFromDisk >= 4)
            {
                foreach (Upgrade item in cashUpgradeList)
                {
                    try {
                        if (info.GetBoolean("upgrade_" + item.saveName))
                        {
                            item.applyUpgrade();
                        }
                        //item.setIsPurchased(info.GetBoolean("upgrade_" + item.saveName));
                    }
                    catch (SerializationException e) {
                        Debug.Log(e);
                    }
                }
                if (Main.saveVersionFromDisk >= 6)
                {
                    foreach (Upgrade item in renownUpgradeList)
                    {
                        try {
                            if (info.GetBoolean("renown_upgrade_" + item.saveName))
                            {
                                item.applyUpgrade();
                            }
                            //item.setIsPurchased(info.GetBoolean("renown_upgrade_" + item.saveName));
                        }
                        catch (SerializationException e) {
                            Debug.Log(e);
                        }
                    }
                }
            }
            else
            {
                int i = 0;
                foreach (Upgrade item in cashUpgradeList)
                {
                    if (i < 16)
                    {
                        item.setIsPurchased(info.GetBoolean("upgrade_" + i));
                    }
                    i++;
                }
            }
            if (Main.saveVersionFromDisk >= 8)
            {
                for (int i = 0; i < availableMasters.Length; i++)
                {
                    availableMasters[i] = (Master)info.GetValue("availableMasters_" + i, typeof(Master));
                }
            }
            hasListChanged = true;
            SkillList.readSaveData(ref info, ref context);
        }