/// <summary>
        /// load lib musik
        /// </summary>
        private async void InitMusic()
        {
            this.activeMusic         = new Music();
            this.activeMusicLibrary  = new MusicLibrary();
            this.musicStorageManager = new MusicStorageManager();
            MusicLibrary _loadedLibrary = await this.musicStorageManager.LoadMusicLibrary();

            if (_loadedLibrary != null)
            {
                this.activeMusicLibrary = _loadedLibrary;
                int librarySize = activeMusicLibrary.musicLibrary.Count;
                if (librarySize != 0)
                {
                    Random musicRandomer = new Random();
                    this.activeMusic = activeMusicLibrary.musicLibrary[musicRandomer.Next(0, librarySize)];
                    this.PlayingActiveMusic(activeMusic);
                    Debug.WriteLine("library is exist, selecting a random music >" + this.activeMusic.musicName);
                }
                else
                {
                    Debug.WriteLine("library is empty >");
                }
                this.MusicListView.DataContext  = activeMusicLibrary;
                this.MusicListView.SelectedItem = activeMusic;
            }
            else
            {
                Debug.WriteLine("unable to load library to stage >");
            }
        }
Beispiel #2
0
        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;
            }
        }