Exemple #1
0
        private void CreateItemBtn_Click(object sender, EventArgs e)
        {
            Items item = new TextAdventure.Items();



            item.ItemTitle       = roomTitle.Text;
            item.ItemDescription = roomDescrip.Text;

            XmlSerializer ser = new XmlSerializer(typeof(Items));
            //creates the xml file
            TextWriter tw = new StreamWriter("itemFile.xml");

            ser.Serialize(tw, item);
            tw.Close();
        }
Exemple #2
0
        //save all data to xml
        private void button1_Click(object sender, EventArgs e)
        {
            //create room coordinates
            //using saved xcoord and ycoord variables set by user
            rooms = new Rooms[xInt, yInt];

            XmlSerializer serCoords = new XmlSerializer(typeof(Rooms[, ]));

            //create room

            //creates a new object
            Rooms room = new TextAdventure.Rooms();

            //setting object variables
            room.RoomTitle       = roomTitle.Text;
            room.RoomDescription = roomDescrip.Text;

            //
            XmlSerializer ser2 = new XmlSerializer(typeof(Rooms));
            //creates the xml file
            TextWriter tw2 = new StreamWriter("itemFile.xml");

            ser2.Serialize(tw2, room);


            tw2.Close();

            //create item
            Items item = new TextAdventure.Items();

            item.ItemTitle       = itemTitle.Text;
            item.ItemDescription = itemDescrip.Text;

            XmlSerializer ser = new XmlSerializer(typeof(Items));
            //creates the xml file
            TextWriter tw = new StreamWriter("itemFile.xml");

            ser.Serialize(tw, item);
            tw.Close();

            //set exit
            //using saved string value as the direction.
            room.AddExit(exitString);
        }