async void PlayerPrefInit() { try { Player loadedPlayer = await playerPrefStorageManager.LoadPlayerPref(); if (loadedPlayer != null) { activePlayer = loadedPlayer; } BGMMenu.Volume = (double)activePlayer.volumePref * 0.1; VolumeSlider.Value = activePlayer.volumePref; PlayerCoin.DataContext = activePlayer; //select opening list view (currently wore) //var selectedQuery = (AvatarSource)(from selectedAva in headAvaList // where selectedAva.avaIndex == activePlayer.headAvaIndex // select selectedAva).FirstOrDefault(); HeadAvaListView.SelectedItem = (AvatarSource)(from selectedAva in headAvaList where selectedAva.avaIndex == activePlayer.headAvaIndex select selectedAva).FirstOrDefault(); selectedHeadAvaPath = ((AvatarSource)HeadAvaListView.SelectedItem).imgPath; TopAvaListView.SelectedItem = (AvatarSource)(from selectedAva in topAvaList where selectedAva.avaIndex == activePlayer.topAvaIndex select selectedAva).FirstOrDefault(); selectedTopAvaPath = ((AvatarSource)TopAvaListView.SelectedItem).imgPath; BottomAvaListView.SelectedItem = (AvatarSource)(from selectedAva in bottomAvaList where selectedAva.avaIndex == activePlayer.bottomAvaIndex select selectedAva).FirstOrDefault(); selectedBottomAvaPath = ((AvatarSource)BottomAvaListView.SelectedItem).imgPath; } catch (Exception e) { Debug.WriteLine("fail opening player pref >" + e.Message); } }
private async void GameInit() { punchManager = new PunchManager(); punchKeyStorageManager = new PunchKeySotrageManager(); musicStorageManager = new MusicStorageManager(); playerPrefStorageManager = new PlayerPrefStorageManager(); gameState = GameState.Unavaliable; //UI InitLayer.Visibility = Visibility.Visible; LayerMain.Visibility = Visibility.Visible; PauseLayer.Visibility = Visibility.Collapsed; EndLayer.Visibility = Visibility.Collapsed; InputPanel.Visibility = Visibility.Collapsed; ChallengeHud.Visibility = Visibility.Collapsed; MultiplayerHud.Visibility = Visibility.Collapsed; //multiplayer activePlayer = new Player[] { new Player(), new Player() }; //loading player Player loadedPlayer = await playerPrefStorageManager.LoadPlayerPref(); if (selectedGameMode != MusicSelect.GameMode.Multiplayer && Definitions.usingPlayerPref) { if (loadedPlayer != null) { activePlayer[0] = loadedPlayer; } activePlayer[0].ActivingPlayerAvatar(); } BGMPlayer.Volume = (double)activePlayer[0].volumePref * 0.1; activePlayer[0].comboTextBlock = FirstPlayerComboText; activePlayer[0].scoreTextBlock = FirstPlayerScoreText; activePlayer[0].comboTextBlock.Text = ""; activePlayer[0].scoreTextBlock.Text = activePlayer[0].currentScore.ToString(); if (selectedGameMode == MusicSelect.GameMode.Multiplayer) { activePlayer[1].comboTextBlock = SecondPlayerComboText; activePlayer[1].scoreTextBlock = SecondPlayerScoreText; activePlayer[1].comboTextBlock.Text = ""; activePlayer[1].scoreTextBlock.Text = activePlayer[1].currentScore.ToString(); SecondPlayerHud.Visibility = Visibility.Visible; MultiplayerHud.Visibility = Visibility.Visible; //MultiplayerHud.DataContext = this; //foreach (var avaImage in activePlayer[1].activeAvatar.avaImages) //{ // gameCanvas.Children.Add(avaImage); //} } else { SecondPlayerHud.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } if (selectedGameMode == MusicSelect.GameMode.Challenge) { ChallengeHud.Visibility = Visibility.Visible; challengeFullGauge = 0; if (activeMusic.selectedMusicMode == Music.MusicMode.EasyChallenge) { challengeFullGauge = Definitions.EasyChallengeFullGauge; } else if (activeMusic.selectedMusicMode == Music.MusicMode.NormalChallenge) { challengeFullGauge = Definitions.NormalChallengeFullGauge; } else if (activeMusic.selectedMusicMode == Music.MusicMode.HardChallenge) { challengeFullGauge = Definitions.HardChallengeFullGauge; } challengeGauge = challengeFullGauge; //ChallengeHud.DataContext = this; } if (activeMusic.selectedMusicMode == Music.MusicMode.InputMode) { FirstPlayerHud.Visibility = Visibility.Collapsed; } }