Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //if (character.characterHealth <= 0)
        //{
        //    PlayerPrefs.SetInt("Fail", 1);
        //    SceneManager.LoadScene("Result");
        //}

        //if (!music.isPlaying) {
        //    PlayerPrefs.SetInt("Fail", 0);
        //    PlayerPrefs.SetString("CurrentScene", SceneManager.GetActiveScene().name);
        //    PlayerPrefs.SetString("SongName", music.clip.name);
        //    PlayerPrefs.SetInt("Combo", maxCombo);

        //    SceneManager.LoadScene("Result");
        //}

        // handle Combo Number
        if (maxCombo <= comboCount)
        {
            maxCombo = comboCount;
        }
        comboText.text = comboCount.ToString();

        // Handle Player Health
        healthBar.value = character.characterHealth / character.characterMaxHealth;
        if (healthBar.value > 0.3)
        {
            healthBarFill.color = Color.green;
        }
        else
        {
            healthBarFill.color = Color.red;
        }


        songPosition   = (float)AudioSettings.dspTime - dsptimesong;
        songPosInBeats = (float)Math.Round((songPosition / secPerBeat), 1);

        if (upNextIndex < l1UpNotes.Length && l1UpNotes[upNextIndex] < songPosInBeats)
        {
            if (l1UpNotes[upNextIndex] == l1LeftNotes[leftNextIndex])
            {
                upNoteSpawner.SpawnDoubleNote();
                upNextIndex++;
                leftNoteSpawner.SpawnDoubleNote();
                leftNextIndex++;
            }
            else if (l1UpNotes[upNextIndex] == l1RightNotes[rightNextIndex])
            {
                upNoteSpawner.SpawnDoubleNote();
                upNextIndex++;
                rightNoteSpawner.SpawnDoubleNote();
                rightNextIndex++;
            }
            else
            {
                upNoteSpawner.SpawnSingleNote();
                upNextIndex++;
            }
        }
        if (leftNextIndex < l1LeftNotes.Length && l1LeftNotes[leftNextIndex] < songPosInBeats)
        {
            if (l1LeftNotes[leftNextIndex] == l1UpNotes[upNextIndex])
            {
                leftNoteSpawner.SpawnDoubleNote();
                leftNextIndex++;
                upNoteSpawner.SpawnDoubleNote();
                upNextIndex++;
            }
            else if (l1LeftNotes[upNextIndex] == l1RightNotes[rightNextIndex])
            {
                leftNoteSpawner.SpawnDoubleNote();
                leftNextIndex++;
                rightNoteSpawner.SpawnDoubleNote();
                rightNextIndex++;
            }
            else
            {
                leftNoteSpawner.SpawnSingleNote();
                leftNextIndex++;
            }
        }
        if (rightNextIndex < l1RightNotes.Length && l1RightNotes[rightNextIndex] < songPosInBeats)
        {
            if (l1RightNotes[leftNextIndex] == l1UpNotes[upNextIndex])
            {
                rightNoteSpawner.SpawnDoubleNote();
                rightNextIndex++;
                upNoteSpawner.SpawnDoubleNote();
                upNextIndex++;
            }
            else if (l1RightNotes[rightNextIndex] == l1LeftNotes[upNextIndex])
            {
                rightNoteSpawner.SpawnDoubleNote();
                rightNextIndex++;
                leftNoteSpawner.SpawnDoubleNote();
                leftNextIndex++;
            }
            else
            {
                rightNoteSpawner.SpawnSingleNote();
                rightNextIndex++;
            }
        }
    }
Exemplo n.º 2
0
    void SpawningNotes(float[] upNotes, float[] leftNotes, float[] rightNotes)
    {
        //print("Right :" + rightNextIndex + " , " + rightNotes.Length);
        //print("Up :" + upNextIndex + " , " + upNotes.Length);
        //print("Left :" + leftNextIndex + " , " +leftNotes.Length);

        if (upNextIndex >= upNotes.Length)
        {
            upEnd = true;
            print("up ended.");
        }
        if (leftNextIndex >= leftNotes.Length)
        {
            leftEnd = true;
            print("left ended.");
        }
        if (rightNextIndex >= rightNotes.Length)
        {
            rightEnd = true;
            print("right ended.");
        }

        if (upNextIndex < upNotes.Length && upNotes[upNextIndex] < songPosInBeats)
        {
            if (!leftEnd || !rightEnd)
            {
                if (!leftEnd && upNotes[upNextIndex] == leftNotes[leftNextIndex])
                {
                    upNoteSpawner.SpawnDoubleNote();
                    upNextIndex++;
                    leftNoteSpawner.SpawnDoubleNote();
                    leftNextIndex++;
                }
                else if (!rightEnd && upNotes[upNextIndex] == rightNotes[rightNextIndex])
                {
                    upNoteSpawner.SpawnDoubleNote();
                    upNextIndex++;
                    rightNoteSpawner.SpawnDoubleNote();
                    rightNextIndex++;
                }
                else
                {
                    upNoteSpawner.SpawnSingleNote();
                    upNextIndex++;
                }
            }
            else
            {
                upNoteSpawner.SpawnSingleNote();
                upNextIndex++;
            }
        }
        if (leftNextIndex < leftNotes.Length && leftNotes[leftNextIndex] < songPosInBeats)
        {
            if (upNextIndex < upNotes.Length || rightNextIndex < rightNotes.Length)
            {
                if (!upEnd && leftNotes[leftNextIndex] == upNotes[upNextIndex])
                {
                    leftNoteSpawner.SpawnDoubleNote();
                    leftNextIndex++;
                    upNoteSpawner.SpawnDoubleNote();
                    upNextIndex++;
                }
                else if (!rightEnd && leftNotes[leftNextIndex] == rightNotes[rightNextIndex])
                {
                    leftNoteSpawner.SpawnDoubleNote();
                    leftNextIndex++;
                    rightNoteSpawner.SpawnDoubleNote();
                    rightNextIndex++;
                }
                else
                {
                    leftNoteSpawner.SpawnSingleNote();
                    leftNextIndex++;
                }
            }
            else
            {
                leftNoteSpawner.SpawnSingleNote();
                leftNextIndex++;
            }
        }
        if (rightNextIndex < rightNotes.Length && rightNotes[rightNextIndex] < songPosInBeats)
        {
            if (!upEnd)
            {
                if (rightNotes[rightNextIndex] == upNotes[upNextIndex])
                {
                    rightNoteSpawner.SpawnDoubleNote();
                    rightNextIndex++;
                    upNoteSpawner.SpawnDoubleNote();
                    upNextIndex++;
                }
                else
                {
                    rightNoteSpawner.SpawnSingleNote();
                    rightNextIndex++;
                }
            }
            else if (!leftEnd)
            {
                if (rightNotes[rightNextIndex] == leftNotes[leftNextIndex])
                {
                    rightNoteSpawner.SpawnDoubleNote();
                    rightNextIndex++;
                    leftNoteSpawner.SpawnDoubleNote();
                    leftNextIndex++;
                }
                else
                {
                    rightNoteSpawner.SpawnSingleNote();
                    rightNextIndex++;
                }
            }
            else
            {
                rightNoteSpawner.SpawnSingleNote();
                rightNextIndex++;
            }
        }
    }