Beispiel #1
0
        public async Task <bool> GenerateNoteSequence(int musicMode)
        {
            //load available punching notes
            PunchKeySotrageManager punchStorageManager = new PunchKeySotrageManager();
            NoteLibrary            availableNotebrary  = await punchStorageManager.LoadNoteLibrary();

            List <int>[] noteArray = new List <int>[4] {
                new List <int>(), new List <int>(), new List <int>(), new List <int>()
            };                                                                                                               //indexing -> 0 : 1 key----1: 2 key----2: 3 key----3: 4 key

            foreach (Note note in availableNotebrary.noteLibrary)
            {
                int difficulty = note.serPunchingJoints.Count - 1;
                if (difficulty >= 0 && difficulty < 4)
                {
                    noteArray[difficulty].Add(note.noteId);
                }
            }

            //difficulty probability array
            int[] difficultyProbability;
            PunchKeyMode = musicMode;
            switch (PunchKeyMode)
            {
            case (int)Music.MusicMode.Exercise:
                difficultyProbability = new int[5] {
                    50, 35, 10, 5, 65
                };
                break;

            case (int)Music.MusicMode.EasyChallenge:
                difficultyProbability = new int[5] {
                    65, 35, 5, 0, 60
                };
                break;

            case (int)Music.MusicMode.NormalChallenge:
                difficultyProbability = new int[5] {
                    35, 50, 10, 5, 45
                };
                break;

            case (int)Music.MusicMode.HardChallenge:
                difficultyProbability = new int[5] {
                    25, 55, 10, 10, 30
                };
                break;

            default:
                difficultyProbability = new int[5];
                break;
            }
            //Generate sequence based on probability
            NoteSequence = new List <int>();
            for (int i = 0; i < Definitions.temporaryNoteLenght; i++)
            {
                //create distribution function
                int rnd = fastRandom(i, 1, 100);
                int cummuativeDistribution = 0;
                for (int j = 0; j < noteArray.Length; j++)
                {
                    cummuativeDistribution += difficultyProbability[j]; //kumulatif cuma dari index 0 sampai 3, 1note, 2note, 3note, 4note
                    if (rnd < cummuativeDistribution)
                    {
                        if (j > 2)
                        {
                            NoteSequence.Add(0);
                        }
                        NoteSequence.Add((noteArray[j])[fastRandom(i + j, 0, noteArray[j].Count)]);     //random dari daftar note sesuai kumulatif
                        break;
                    }
                }

                //create break function
                rnd = fastRandom(i, 1, 100);
                if (rnd < difficultyProbability[4])
                {
                    NoteSequence.Add(0);
                }
            }

            return(true);
        }
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;
            }
        }