Exemplo n.º 1
0
    void FixedUpdate()
    {
        gameTimer -= Time.deltaTime;
        gameTimer  = (gameTimer < 0.0f) ? 0.0f : gameTimer;
        if (!spikesDropped)
        {
            timerText.GetComponent <Text> ().text = Mathf.Floor(gameTimer).ToString();
        }
        else
        {
            theText.fontSize = 1;
            theText.text     = "Balloons\nDestroyed\n" + balloonsDestroyed;
            Debug.Log(totalEvilBalloons);
            Debug.Log(evilBalloonsKilled);
            if (reportingSpikes == expectedSpikes && evilBalloonsKilled == totalEvilBalloons)
            {
                endWaitTimer = (endWaitTimer <= 0.0f) ? 0.0f : endWaitTimer - Time.deltaTime;
                if (endWaitTimer <= 0.0f)
                {
                    nextLevelTimer = (nextLevelTimer <= 0.0f) ? 0.0f : nextLevelTimer - Time.deltaTime;
                    if (balloonsDestroyed == 0)
                    {
                        theText.text = "Next level\nin " + ((nextLevelTimer > 0.0f) ? Mathf.Floor(nextLevelTimer) : 0);
                    }
                    else if (balloonsDestroyed >= 1)
                    {
                        theText.text = "Retry in\nin " + ((nextLevelTimer > 0.0f) ? Mathf.Floor(nextLevelTimer) : 0);
                    }
                    if (nextLevelTimer <= 0.0f)
                    {
                        if (balloonsDestroyed == 0)
                        {
                            DontDestroyOnLoad(tracker);
                            tracker.completedLevel();
                        }
                        else if (tracker.currLevel != 0)
                        {
                            DontDestroyOnLoad(tracker);
                        }
                        SceneManager.LoadScene(tracker.getLevelName());
                    }
                }
            }
        }

        if (gameTimer >= 0 && gameTimer <= 8.0f && !gameObject.GetComponent <AudioSource>().isPlaying)
        {
            gameObject.GetComponent <AudioSource>().Play();
        }
        if (gameTimer == 0.0f)
        {
            if (!spikesDropped)
            {
                spikesDropped = true;
                Spikes spikes = GameObject.FindObjectOfType <Spikes>();
                spikes.dropSpikes();
            }
        }
    }
Exemplo n.º 2
0
 public void startNew()
 {
     levelTracker.currLevel = 0;
     DontDestroyOnLoad(levelTracker);
     SceneManager.LoadScene(levelTracker.getLevelName());
 }