示例#1
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            //this.GameSource = XElement.Load("game.xml");
            XmlSerializer serializer = new XmlSerializer(typeof(Game));

            FileStream fs = new FileStream("game.xml", FileMode.Open);
            this.GameSource = (Game)serializer.Deserialize(fs);
            fs.Close();

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");

            this.Game = new SaveGameData();
            this.isLoadedGame = this.LoadGame("Autosave.xml");
            if (isLoadedGame == false)
            {
                this.InitializeGame();
            }

            this.ExecuteEpizode(this.Game.CurrentEpizode);
        }
示例#2
0
 private bool LoadGame(string file)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
     if (System.IO.File.Exists(file) == true)
     {
         FileStream fs = new FileStream(file, FileMode.Open);
         this.Game = (SaveGameData)serializer.Deserialize(fs);
         fs.Close();
         this.isLoadedGame = true;
         return true;
     }
     return false;
 }