Exemplo n.º 1
0
    private void GameInit()
    {
        Time.timeScale = 1;
        isPaused       = false;
        gameOver       = false;
        hasStarted     = false;
        GameOverPanel.SetActive(false);
        pausePanel.SetActive(false);
        spawner1.SetActive(true);
        spawner2.SetActive(false);

        t = 0;
        d = 0;
        l = 0;

        gameObject.GetComponent <MouseControl> ().enabled = true;
        clearPickups();

        EnergyLevel   = 100;
        DecayInterval = 0.5f;
        Score         = 0;
        multiplier    = 1;
        currentLevel  = 1; // TEMPORARY FIX
        HighScore     = PlayerPrefs.GetInt("HighScore");

        //scoreText.text = "" + Score;
        for (int i = 0; i < 3; i++)
        {
            levelCountIcon[i].SetActive(false);
        }

        InitializeLevel(1);

        if (currentLevel == 2)
        {
            PickSpawner.IncreasePickSpeedBy(0.9f);
            InitializeLevel(2);
        }

        if (currentLevel == 3)
        {
            PickSpawner.IncreasePickSpeedBy(1.5f);
            InitializeLevelOnStart(3);
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        t += Time.deltaTime;
        d += Time.deltaTime;
        l += Time.deltaTime;

        energyLevelText.text = "" + EnergyLevel;

        if (hasStarted)
        {
            scoreText.text = "" + Score;
        }

        if (t >= DecayInterval)
        {
            EnergyLevel--;

            if (EnergyLevel < 0)
            {
                EnergyLevel = 0;
            }
            t = 0;
        }

        if (EnergyLevel <= 0) //GAME OVER
        {
            gameOver = true;
            Debug.Log("GAME OVER");
            Time.timeScale = 0;
            GameOverPanel.SetActive(true);
            finalScoreText.text = scoreText.text;
            HighScoreText.text  = "" + HighScore;
        }

        if (EnergyLevel > 100)
        {
            EnergyLevel = 100;
        }

        if (Input.GetKeyDown(KeyCode.Escape) && hasStarted)
        {
            Pause();
        }

        if (d >= 10)
        {
            PickSpawner.IncreasePickSpeedBy(0.2f);
            //DecayInterval /= 1.1f;
            Debug.Log("Decay Interval decreased to " + DecayInterval);
            d = 0;
        }

        if (Score == 25 && currentLevel < 2) //LEVEL 2
        {
            currentLevel++;
            InitializeLevel(2);
            l = 0;
        }

        if (Score == 50 && currentLevel < 3) //LEVEL 3
        {
            currentLevel++;
            InitializeLevel(3);
            l = 0;
        }

        if (currentLevel == 3)
        {
            spawnerSet.transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * 20);
        }
    }