Load() public method

Loads a new room from the provided XmlNode.
public Load ( XmlNode room ) : void
room System.Xml.XmlNode
return void
Example #1
0
        public bool Load(string name)
        {
            XmlDocument document = new XmlDocument();
            XmlNode     collection;
            XmlElement  element;

            try
            {
                document.Load(name);
            }
            catch
            {
                Global.Error("ERROR: Area '" + name + "' not found.\n");
                return(false);
            }

            element = document.DocumentElement;
            Name    = element.GetAttribute("name");

            Global.Log("  " + Name + ":\n");

            collection = element["rooms"];
            Room newRoom;

            foreach (XmlNode node in collection.ChildNodes)
            {
                newRoom = new Room(Convert.ToInt32(node.Attributes["index"].Value));
                newRoom.Load(node, this);
                Rooms.Add(newRoom);
            }

            collection = element["mobs"];
            Mob newMob;

            foreach (XmlNode node in collection.ChildNodes)
            {
                newMob = new Mob(node);
            }

            Global.AreaTable.Add(Global.AreaTable.Count, this);
            Global.Log("  " + Name + " loaded, ");

            ForceSpawn();

            Global.Log("spawned\n");

            return(true);
        }
Example #2
0
        public bool Load(string name)
        {
            XmlDocument document = new XmlDocument();
            XmlNode collection;
            XmlElement element;

            try
            {
                document.Load(name);
            }
            catch
            {
                Global.Error("ERROR: Area '" + name + "' not found.\n");
                return false;
            }

            element = document.DocumentElement;
            Name = element.GetAttribute("name");

            Global.Log("  " + Name + ":\n");

            collection = element["rooms"];
            Room newRoom;
            foreach (XmlNode node in collection.ChildNodes)
            {
                newRoom = new Room(Convert.ToInt32(node.Attributes["index"].Value));
                newRoom.Load(node, this);
                Rooms.Add(newRoom);
            }

            collection = element["mobs"];
            Mob newMob;
            foreach (XmlNode node in collection.ChildNodes)
            {
                newMob = new Mob(node);
            }

            Global.AreaTable.Add(Global.AreaTable.Count, this);
            Global.Log("  " + Name + " loaded, ");

            ForceSpawn();

            Global.Log("spawned\n");

            return true;
        }