Exemplo n.º 1
0
    void Update()
    {
        timer += Time.deltaTime;

        enemySpawnPoints = GameObject.FindGameObjectsWithTag("EnemySpawner");
        remainingEnemies = GameObject.FindGameObjectsWithTag("Enemy");

        scoreText.text = "SCORE:\n" + score.ToString();

        if (newUpdate == false && timer >= 3)
        {
            updateText.text = "";
            actionText.text = updateText.text;
        }
        else if (newUpdate == true && timer < 3 && !gameWon)
        {
            actionText.text = updateText.text;
        }

        if (weaponSwitch.selectedWeapon == 0)
        {
            pinkHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 1);
            blueHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 0);
            violetHUD.GetComponent <Image>().color = new Color(1, 1, 1, 0);
            pinkHand.enabled   = true;
            blueHand.enabled   = false;
            violetHand.enabled = false;
        }
        else if (weaponSwitch.selectedWeapon == 1)
        {
            pinkHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 0);
            blueHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 1);
            violetHUD.GetComponent <Image>().color = new Color(1, 1, 1, 0);
            pinkHand.enabled   = false;
            blueHand.enabled   = true;
            violetHand.enabled = false;
        }
        else if (weaponSwitch.selectedWeapon == 2)
        {
            pinkHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 0);
            blueHUD.GetComponent <Image>().color   = new Color(1, 1, 1, 0);
            violetHUD.GetComponent <Image>().color = new Color(1, 1, 1, 1);
            pinkHand.enabled   = false;
            blueHand.enabled   = false;
            violetHand.enabled = true;
        }

        if (alienKey == true && ending == false && gameOver == false)
        {
            alienCheck.enabled = true;
        }

        if (pizzaKey == true && ending == false && gameOver == false)
        {
            pizzaCheck.enabled = true;
        }

        if (smileyKey == true && ending == false && gameOver == false)
        {
            smileyCheck.enabled = true;
        }

        if (alienKey == true && pizzaKey == true && smileyKey == true && ending == false)
        {
            playMusic.PlaySelectedMusic(2);
            lightSwitch.dimmed = true;
            bgColor.dimmed     = true;
            StartCoroutine(EndGame());
            AddPoints(100);
            ending = true;
        }

        if (ending == true)
        {
            enemyCountdown.text = "BADDIES LEFT: " + remainingEnemies.Length.ToString();
        }

        if (isDead == true && gameWon == false && gameOver == false)
        {
            gameOver = true;
            StartCoroutine(GameOver());
        }

        if (ending == true && remainingEnemies.Length == 0 && gameWon == false)
        {
            gameWon = true;
            playMusic.FadeFXDown(5f);
            StartCoroutine(GameWon());
            timer = 0;
        }

        if (gameWon == true)
        {
            timer += Time.deltaTime;

            playerMove.playerWalkingSpeed = 10f;
            playerMove.playerRunningSpeed = 15f;
            playerMove.jumpStrength       = 5f;

            if (timer < 3)
            {
                weaponSwitch.selectedWeapon = 0;
            }
            else if (timer >= 3 && timer < 6)
            {
                weaponSwitch.selectedWeapon = 1;
            }
            else if (timer >= 6 && timer < 9)
            {
                weaponSwitch.selectedWeapon = 2;
            }
            else if (timer > 9)
            {
                timer = 0;
            }
        }
    }