Exemplo n.º 1
0
        public MDRDungeon LoadDungeon(Stream source)
        {
            SetupInput(source, 20);

            MDRDungeon result = new MDRDungeon();

            try {
                //find how many levels there are
                int floors = data.ReadMDRWord();

                //make sure it's reasonable
                if ((floors > 255) || (floors < 1))
                {
                    throw new Exception("Invalid number of levels in file, found " + floors + " expecting between 1 and 255");
                }

                //stub fixed width and height
                result.Initialize(32, 32, floors);

                for (int level = 1; level <= floors; level++)
                {
                    result.Floor[level]             = ReadMap(level);
                    result.Floor[level].FloorNumber = level;
                    if (result.Floor[level].Width != 32 || result.Floor[level].Height != 32)
                    {
                        throw new Exception("Floors must all have the standard dimentions.  We expecting 32x32 but found " + result.Floor[level].Width + "x" + result.Floor[level].Height);
                    }
                }
            } finally {
                data.Close();
            }

            return(result);
        }
Exemplo n.º 2
0
    /**
     * Deletes current gamestate (characters, explored map etc) and creates default data.
     * This will causes all characters, maps, etc to be lost
     */
    public void Reset()
    {
        if (!CoM.GameDataLoaded)
        {
            throw new Exception("Can not reset save file until game data has been loaded.");
        }

        SpawnManager = new SpawnManager();

        // Store.
        Store = new MDRStore();
        Store.SetDefault();

        GameStats.AddDefaultStats();

        // Explored dungeon.
        ExploredDungeon = new MDRDungeon();
        ExploredDungeon.Initialize(CoM.Dungeon.Width, CoM.Dungeon.Height, CoM.Dungeon.Floors);

        // characters and party
        CharacterList = loadFromStore <MDRCharacterLibrary>("DefaultCharacters");
        PartyList     = loadFromStore <MDRPartyLibrary>("DefaultParty");

        Trace.Log("Save file reset.");

        _loaded = true;
    }