Example #1
0
        public static void LoadGame(string fileName, bool fullLoad)
        {
            var bundle = GameBundle(fileName);

            Challenges = bundle.GetInt(CHALLENGES);

            Level = null;
            Depth = -1;

            if (fullLoad)
            {
                PathFinder.SetMapSize(Level.Width, Level.Height);
            }

            Scroll.Restore(bundle);
            Potion.Restore(bundle);
            Wand.Restore(bundle);
            Ring.Restore(bundle);

            PotionOfStrength = bundle.GetInt(POS);
            ScrollsOfUpgrade = bundle.GetInt(SOU);
            ArcaneStyli      = bundle.GetInt(AS);
            DewVial          = bundle.GetBoolean(DV);
            Transmutation    = bundle.GetInt(WT);

            if (fullLoad)
            {
                Chapters = new HashSet <int?>();
                var ids = bundle.GetIntArray(CHAPTERS);
                if (ids != null)
                {
                    foreach (var id in ids)
                    {
                        Chapters.Add(id);
                    }
                }

                var quests = bundle.GetBundle(QUESTS);
                if (!quests.IsNull)
                {
                    Ghost.Quest.RestoreFromBundle(quests);
                    Wandmaker.Quest.RestoreFromBundle(quests);
                    Blacksmith.Quest.RestoreFromBundle(quests);
                    Imp.Quest.RestoreFromBundle(quests);
                }
                else
                {
                    Ghost.Quest.reset();
                    Wandmaker.Quest.Reset();
                    Blacksmith.Quest.Reset();
                    Imp.Quest.Reset();
                }

                Room.RestoreRoomsFromBundle(bundle);
            }

            var badges = bundle.GetBundle(BADGES);

            if (!badges.IsNull)
            {
                Badge.LoadLocal(badges);
            }
            else
            {
                Badge.Reset();
            }

            var qsClass = bundle.GetString(QUICKSLOT);

            if (qsClass != null)
            {
                try
                {
                    Quickslot = (Item)Activator.CreateInstance(Type.GetType(qsClass));
                }
                catch (ClassNotFoundException)
                {
                }
            }
            else
            {
                Quickslot = null;
            }


            var version = bundle.GetString(Version);

            Hero = null;
            Hero = (Hero)bundle.Get(HERO);

            Gold  = bundle.GetInt(GOLD);
            Depth = bundle.GetInt(DEPTH);

            Statistics.RestoreFromBundle(bundle);
            Journal.RestoreFromBundle(bundle);
        }