Beispiel #1
0
        public void DisplayScores()
        {
            Canvas completionScreen = MonoBehaviour.Instantiate(Resources.Load <Canvas>("Prefabs/CompletionUI"));

            CompletionScript completionScript = completionScreen.GetComponent <CompletionScript>();

            completionScript.displayCompletionUI();

            Assert.IsTrue(completionScript.highScoreIsVisible());
            Assert.IsTrue(completionScript.userScoreIsVisible());
        }
Beispiel #2
0
    public void EndGame()
    {
        if (score.getNoteMissed() == false && confettiCalled == false) // Full Combo's reward
        {
            confettiCalled = true;
            //Celebrate here
            confetti.Play();
            Debug.Log("Perfect score received.");
            songData.savePerfectScore();
        }

        score.calculateHighScore();
        Debug.Log(score.getHighScore().ToString());
        completionUI.displayCompletionUI();
        songData.CalculateCoins();

        StartCoroutine(WaitToEnd(5));
    }
Beispiel #3
0
    IEnumerator SpawnNote()
    {
        yield return(new WaitForSeconds(startDelay));

        while (songLength - currentPlayedTime > 2.5) // Stops spawning with 2.5s of song remaining
        {
            float randomNum = UnityEngine.Random.Range(0.0f, 1.0f);

            if (firstSpawn) // Ensures a note spawns on the first beat, rather than a gap or an obstacle
            {
                firstSpawn = false;

                if (randomNum >= 0 && randomNum < 0.33)
                {// Spawns Note 1
                    createNote(noteOne, noteSpawnPositions[0]);
                }
                else if (randomNum >= 0.33 && randomNum < 0.66)
                { // Spawns Note 2
                    createNote(noteTwo, noteSpawnPositions[1]);
                }
                else if (randomNum >= 0.66 && randomNum <= 1)
                { // Spawns Note 3
                    createNote(noteThree, noteSpawnPositions[2]);
                }
            }

            else // Standard Spawning Method
            {
                yield return(new WaitForSeconds(secsPerBeat / difficultyMultiplier));

                if (randomNum >= 0 && randomNum <= 0.25)
                { // Spawns Note 1
                    createNote(noteOne, noteSpawnPositions[0]);
                }
                else if (randomNum >= 0.30 && randomNum <= 0.55)
                { // Spawns Note 2
                    createNote(noteTwo, noteSpawnPositions[1]);
                }
                else if (randomNum >= 0.60 && randomNum <= 0.85)
                { // Spawns Note 3
                    createNote(noteThree, noteSpawnPositions[2]);
                }
                else if (randomNum >= 0.87 && randomNum < 0.95)
                { // Spawns Obstacle
                    int     index   = UnityEngine.Random.Range(0, noteSpawnPositions.Length);
                    Vector3 currPos = noteSpawnPositions[index];
                    //currPos.y += 0.7f; // Increases the spawn height so that the Obstacle is not in the ground.
                    createNote(obstacle, currPos);
                }
            }
        }

        yield return(new WaitForSeconds(5.5f));

        if (score.getNoteMissed() == false) // Full Combo's reward
        {
            //Celebrate here
            confetti.Play(); //
            Debug.Log("Woop");
            songData.savePerfectScore();
        }

        score.calculateHighScore();
        Debug.Log(score.getHighScore().ToString());
        completionUI.displayCompletionUI();
        songData.CalculateCoins(); //calculate amount of coins based on score and add to their current amount

        //if (score.getNoteMissed() == false) // Stops celebration
        //{
        //    yield return new WaitForSeconds(5f); // GIves time for celebration and to display UI
        //    confetti.Stop();
        //}

        yield return(new WaitForSeconds(5f));

        FinalScoreObject = GameObject.Find("FinalScoreObject");
        FinalScoreObject.transform.SetParent(null);
        DontDestroyOnLoad(FinalScoreObject);

        GameObject songGameObject = GameObject.FindGameObjectWithTag("Song");

        Destroy(songGameObject);

        SceneManager.LoadScene("SongList");
    }