//LÄSER AV DEN NEADSPARADE FILEN OCH LADDAR SEDAN UPP DE SPARADE VÄRDEN public void LoadFromDevice(IAsyncResult result) { device = StorageDevice.EndShowSelector(result); IAsyncResult r = device.BeginOpenContainer(containerName, null, null); result.AsyncWaitHandle.WaitOne(); StorageContainer container = device.EndOpenContainer(r); result.AsyncWaitHandle.Close(); if (container.FileExists(filename)) { Stream stream = container.OpenFile(filename, FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(SaveGame)); SaveGame SaveData = (SaveGame)serializer.Deserialize(stream); stream.Close(); container.Dispose(); //Update the game based on the save game file l_Level = SaveData.CurrentLevel; l_CurrentDifficulty = SaveData.Difficulty; l_PlayerPos = SaveData.PlayerPosition; l_PlayerHealth = SaveData.PlayerHp; } }
//FUNCKTION SOM SÄTTER SPELARENS LIV BEOROENDE PÅ SVÅRIGHETSGRAD internal void SetDifficultyHealth(StateHandler.Difficulty a_difficulty) { m_gameMode = a_difficulty; switch (a_difficulty) { case StateHandler.Difficulty.EASY: m_lives = 200; break; case StateHandler.Difficulty.MEDIUM: m_lives = 100; break; case StateHandler.Difficulty.HARD: m_lives = 50; break; } }