Example #1
0
        public static void SaveGame(string fileName)
        {
            try
            {
                var bundle = new Bundle();

                bundle.Put(Version, Game.version);
                bundle.Put(CHALLENGES, Challenges);
                bundle.Put(HERO, Hero);
                bundle.Put(GOLD, Gold);
                bundle.Put(DEPTH, Depth);

                bundle.Put(POS, PotionOfStrength);
                bundle.Put(SOU, ScrollsOfUpgrade);
                bundle.Put(AS, ArcaneStyli);
                bundle.Put(DV, DewVial);
                bundle.Put(WT, Transmutation);

                var count = 0;
                var ids   = new int?[Chapters.Count];
                foreach (var id in Chapters)
                {
                    ids[count++] = id;
                }

                bundle.Put(CHAPTERS, ids);

                var quests = new Bundle();
                Ghost.Quest.StoreInBundle(quests);
                Wandmaker.Quest.StoreInBundle(quests);
                Blacksmith.Quest.StoreInBundle(quests);
                Imp.Quest.StoreInBundle(quests);
                bundle.Put(QUESTS, quests);

                Room.StoreRoomsInBundle(bundle);

                Statistics.StoreInBundle(bundle);
                Journal.StoreInBundle(bundle);

                if (Quickslot != null)
                {
                    bundle.Put(QUICKSLOT, Quickslot.Name);
                }

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

                var badges = new Bundle();
                Badge.SaveLocal(badges);
                bundle.Put(BADGES, badges);

                var output = Game.Instance.OpenFileOutput(fileName, FileCreationMode.Private);
                Bundle.Write(bundle, output);
                output.Close();
            }
            catch (Exception)
            {
                GamesInProgress.Unknown = Hero.heroClass;
            }
        }