Example #1
0
        public static void Init()
        {
#if !Console
            Challenges = PixelDungeon.Challenges();
#endif

            Actor.Clear();

            PathFinder.SetMapSize(Level.Width, Level.Height);

            Scroll.InitLabels();
            Potion.InitColors();
            Wand.InitWoods();
            Ring.InitGems();

            Statistics.Reset();
            Journal.Reset();

            Depth = 0;
            Gold  = 0;

            PotionOfStrength = 0;
            ScrollsOfUpgrade = 0;
            ArcaneStyli      = 0;
            DewVial          = true;
            Transmutation    = Random.IntRange(6, 14);

            Chapters = new HashSet <int?>();

            Ghost.Quest.reset();
            Wandmaker.Quest.Reset();
            Blacksmith.Quest.Reset();
            Imp.Quest.Reset();

            Room.ShuffleTypes();

            Hero = new Hero();
            Hero.Live();

            Badge.Reset();

            StartScene.curClass.InitHero(Hero);
        }
Example #2
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);
        }