/// <summary>
 /// Saves a profile (saved game) to file
 /// </summary>
 public static void SaveToFile(PlayerProfile profile)
 {
     var SaveGamesDirectory = (string)Utilities.Globals.Variables["SaveGamesDirectory"];
     if (profile.savedProfile != null)
     {
         using (var writer = new XmlTextWriter(SaveGamesDirectory + profile.ID + ".wgm", null))
         {
             writer.Formatting = Formatting.Indented;
             profile.savedProfile.WriteTo(writer);
             writer.Close();
         }
     }
 }
        /// <summary>
        /// Loads a saved profile (saved game) from file
        /// </summary>
        public static PlayerProfile LoadFromFile(string profileName)
        {
            var SaveGamesDirectory = (string)Utilities.Globals.Variables["SaveGamesDirectory"];

            var savedGame = new XmlDocument();
            savedGame.LoadXml(
                System.IO.File.ReadAllText(SaveGamesDirectory + profileName + ".wgm"));

            XmlNode playerNode = savedGame.DocumentElement;

            PlayerProfile profile = new PlayerProfile(playerNode.Attributes.GetNamedItem("name").Value);
            profile.savedProfile = savedGame;

            return profile;
        }
        public override void Load()
        {
            ActiveProfile = new PlayerProfile("null");

            MathUtil.Init((float)DefaultSettings.Settings["PixelsPerMeter"]);
            Size = ((Vector2)(Size)Utilities.DefaultSettings.Settings["WindowSize"]) / MathUtil.PixelsPerMeter;

            PhysicsManager = new PhysicsEngine();
            UIManager = new GUIEngine();
            GraphicsManager = new GraphicsEngine();
            GraphicsTemp.load();

            InitGame();
             // InitPhysicsEngine(); <-- called in InitGame
            InitUI();
        }
 public PuzzleDemoState(string ProfileName, bool newProfile)
 {
     if (newProfile)
         ActiveProfile = new PlayerProfile(ProfileName);
     else ActiveProfile = PlayerProfile.LoadFromFile(ProfileName);
 }