コード例 #1
0
 void Save()
 {
     SaveData data = new SaveData()
     {
         sound = Game1.sound,
         fullscreen = graphics.IsFullScreen,
         stretch = Game1.stretch,
         level = Game1.level,
         leben = Game1.leben,
     };
     XmlSerializer writer = new XmlSerializer(data.GetType());
     StreamWriter file = new StreamWriter("bana.na");
     writer.Serialize(file, data);
     file.Close();
 }
コード例 #2
0
 void Load()
 {
     SaveData data = new SaveData();
     XmlSerializer reader = new
        XmlSerializer(data.GetType());
     // Read the XML file.
     if (File.Exists("bana.na"))
     {
         StreamReader file = new StreamReader("bana.na");
         // Deserialize the content of the file into a Book object.
         data = (SaveData)reader.Deserialize(file);
         file.Close();
         stretch = data.stretch;
         sound = data.sound;
         if (data.fullscreen != graphics.IsFullScreen)
         {
             ToggleFullscreen();
         }
         if (data.level <= 5)
         {
             level = data.level;
         }
         else
         {
             level = 1;
         }
         if (level != 1)
         {
             if (leben <= 4 || leben > 0)
             {
                 leben = data.leben;
             }
             else
             {
                 leben = 4;
             }
         }
         else
             leben = 4;
     }
 }