Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
 public static void Disown(Badge badge)
 {
     LoadGlobal();
     _global.Remove(badge);
     _saveNeeded = true;
 }
Ejemplo n.º 4
0
        public static void ValidateBossSlain()
        {
            Badge badge = null;

            switch (Dungeon.Depth)
            {
            case 5:
                badge = BOSS_SLAIN_1;
                break;

            case 10:
                badge = BOSS_SLAIN_2;
                break;

            case 15:
                badge = BOSS_SLAIN_3;
                break;

            case 20:
                badge = BOSS_SLAIN_4;
                break;
            }

            if (badge != null)
            {
                _local.Add(badge);
                DisplayBadge(badge);

                if (badge == BOSS_SLAIN_1)
                {
                    switch (Dungeon.Hero.heroClass.Ordinal())
                    {
                    case HeroClassType.Warrior:
                        badge = BOSS_SLAIN_1_WARRIOR;
                        break;

                    case HeroClassType.Mage:
                        badge = BOSS_SLAIN_1_MAGE;
                        break;

                    case HeroClassType.Rogue:
                        badge = BOSS_SLAIN_1_ROGUE;
                        break;

                    case HeroClassType.Huntress:
                        badge = BOSS_SLAIN_1_HUNTRESS;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                _local.Add(badge);
                if (!_global.Contains(badge))
                {
                    _global.Add(badge);
                    _saveNeeded = true;
                }

                if (_global.Contains(BOSS_SLAIN_1_WARRIOR) && _global.Contains(BOSS_SLAIN_1_MAGE) && _global.Contains(BOSS_SLAIN_1_ROGUE) && _global.Contains(BOSS_SLAIN_1_HUNTRESS))
                {
                    badge = BOSS_SLAIN_1_ALL_CLASSES;
                    if (!_global.Contains(badge))
                    {
                        DisplayBadge(badge);
                        _global.Add(badge);
                        _saveNeeded = true;
                    }
                }
            }
            else if (badge == BOSS_SLAIN_3)
            {
                //switch (Dungeon.Hero.subClass)
                //{
                //    case GLADIATOR:
                //        badge = Badge.BOSS_SLAIN_3_GLADIATOR;
                //        break;
                //    case BERSERKER:
                //        badge = Badge.BOSS_SLAIN_3_BERSERKER;
                //        break;
                //    case WARLOCK:
                //        badge = Badge.BOSS_SLAIN_3_WARLOCK;
                //        break;
                //    case BATTLEMAGE:
                //        badge = Badge.BOSS_SLAIN_3_BATTLEMAGE;
                //        break;
                //    case FREERUNNER:
                //        badge = Badge.BOSS_SLAIN_3_FREERUNNER;
                //        break;
                //    case ASSASSIN:
                //        badge = Badge.BOSS_SLAIN_3_ASSASSIN;
                //        break;
                //    case SNIPER:
                //        badge = Badge.BOSS_SLAIN_3_SNIPER;
                //        break;
                //    case WARDEN:
                //        badge = Badge.BOSS_SLAIN_3_WARDEN;
                //        break;
                //    default:
                //        return;
                //}
                _local.Add(badge);
                if (!_global.Contains(badge))
                {
                    _global.Add(badge);
                    _saveNeeded = true;
                }

                if (_global.Contains(BOSS_SLAIN_3_GLADIATOR) && _global.Contains(BOSS_SLAIN_3_BERSERKER) && _global.Contains(BOSS_SLAIN_3_WARLOCK) && _global.Contains(BOSS_SLAIN_3_BATTLEMAGE) && _global.Contains(BOSS_SLAIN_3_FREERUNNER) && _global.Contains(BOSS_SLAIN_3_ASSASSIN) && _global.Contains(BOSS_SLAIN_3_SNIPER) && _global.Contains(BOSS_SLAIN_3_WARDEN))
                {
                    badge = BOSS_SLAIN_3_ALL_SUBCLASSES;
                    if (!_global.Contains(badge))
                    {
                        DisplayBadge(badge);
                        _global.Add(badge);
                        _saveNeeded = true;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public static bool IsUnlocked(Badge badge)
 {
     return(_global.Contains(badge));
 }