protected override void OnNavigatedTo(NavigationEventArgs e) { playerName = e.Parameter as string; if (playerName != "continue") { StorageFolder folder = ApplicationData.Current.LocalFolder; string fileName = folder.Path + "/" + playerName + ".xml"; if (File.Exists(fileName)) { XMLIO.Load(playerName, Game, myCanvas); } } _mpBgr.Play(); _dispatcherTimer.Start(); }
static public async void Load(string playerName, GameBoard Game, Canvas myCanvas) { int[][] FromLoad = await XMLIO.ReadObjectFromXmlFileAsync(playerName); Game._score = FromLoad[0][0]; Game._lives = FromLoad[0][1]; Game._level = FromLoad[0][2]; Game._gameObjects[0].TopLeftPosistionX = FromLoad[1][1]; for (int i = 2; i < FromLoad.Length; i++) { if (FromLoad[i][0] == 2) { var monster = new MonsterObject(myCanvas, FromLoad[i][1], FromLoad[i][2], Game._level); Game._gameObjects.Add(monster); } if (FromLoad[i][0] == 3) { var bullet = new BulletObject(myCanvas, FromLoad[i][1], FromLoad[i][2]); Game._gameObjects.Add(bullet); } } }
private async void Save(IUICommand command) { await XMLIO.SaveObjectToXml(XMLIO.Trans(Game, Game._gameObjects), playerName); Application.Current.Exit(); }