Exemplo n.º 1
0
        public override void LoadContent() // Loads the content of the level
        {
            base.LoadContent();
            // CODE IS FOR DEBUG WILL BE CHANGED TO BE MORE DYNAMIC AND DEPENDANT ON THE XML LOADERS

            // After the saved data is loaded the data from the save file is placed into their corresponding places (fields)

            // Player name
            PlayerName = saveData.DataSaveValues["PlayerName"];

            // Load the player and its creature from the file
            Player = new Player((Creature)Activator.CreateInstance(null, saveData.DataSaveValues["Character"]).Unwrap());

            // Load the level
            NewLevel(saveData.DataSaveValues["Level"]);

            // Load the health data
            Player.Creature.ChangeMaxHealth(int.Parse(saveData.DataSaveValues["MaxHealth"]));
            Player.Creature.ChangeCurrentHealth(int.Parse(saveData.DataSaveValues["CurrentHealth"]));

            // Load the inventory
            Player.Inventory.LoadInventoryFromData(saveData.InventoryItems);

            // Initiate the high score recorder and start recording
            HighScoreRecorder = new HighScoreRecorder(PlayerName);
            HighScoreRecorder.Start();
        }
Exemplo n.º 2
0
        // Save the game
        public void SaveGame()
        {
            // Save the game
            saveData.Save();

            // Stop the recorder and save the high score
            HighScoreRecorder.Stop();
            HighScoreRecorder.SaveHighScore();
        }