Ejemplo n.º 1
0
    void Update()
    {
        if (pBuyingCas && Input.GetKeyDown(KeyCode.E))
        {
            //This allows the player to unlock higher upgrade levels when a minimum amount of
            //carrots has been met
            if (CarrotScore.carrotScore >= minCarNeededD && gPatches == 80)
            {
                purchaseSound.Play();

                //Spawns the tower model and tower prefab in a position equal to the lvlUnlock
                //and incraeses the lvlUnlock
                Instantiate(CastlePrefab, CasSpawn.position, Quaternion.identity);

                //Changes the minimum amount of carrots needed to unlock the next upgrade
                CarrotScore.carrotScore -= minCarNeededD;

                casBought = true;

                //The initiates the void function in the CarrotScore script
                CarrotScore.UpdateCarrotScore();

                SceneManager.LoadScene("WinScreen");
            }
        }

        if (casBought == true)
        {
            costText.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (pBuyingAB && Input.GetKeyDown(KeyCode.E))
        {
            //This allows the player to unlock higher upgrade levels when a minimum amount of
            //carrots has been met
            if (CarrotScore.carrotScore >= minCarNeededAB && lvlUnlockAB <= 3)
            {
                //Spawns the ally model and ally bunny prefab in a position equal to the lvlUnlock
                //and increases the lvlUnlock
                Instantiate(cPrefabAB, cSpawnAB[lvlUnlockAB].position, Quaternion.identity);
                Instantiate(ABunny, ABSpawn[lvlUnlockAB].position, ABSpawn[lvlUnlockAB].rotation);
                lvlUnlockAB += 1;
                abCount      = lvlUnlockAB;
                purchaseSound.Play();

                //Changes the minimum amount of carrots needed to unlock the next upgrade
                CarrotScore.carrotScore -= minCarNeededAB;
                switch (lvlUnlockAB)
                {
                case 1:
                    minCarNeededAB = 150;
                    break;

                case 2:
                    minCarNeededAB = 200;
                    break;

                case 3:
                    minCarNeededAB = 250;
                    break;

                default:
                    break;
                }

                //The initiates the void function in the CarrotScore script
                CarrotScore.UpdateCarrotScore();
                ABCost.UpdateABCost();

                if (lvlUnlockAB >= 4)
                {
                    abBought = true;
                }
            }
        }

        if (abBought == true)
        {
            costText.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (pBuyingD && Input.GetKeyDown(KeyCode.E))
        {
            //This allows the player to unlock higher upgrade levels when a minimum amount of
            //carrots has been met
            if (CarrotScore.carrotScore >= minCarNeededD && lvlUnlockD <= 3)
            {
                //Spawns the tower model and tower prefab in a position equal to the lvlUnlock
                //and incraeses the lvlUnlock
                Instantiate(cPrefabD, cSpawnD[lvlUnlockD].position, Quaternion.identity);
                Instantiate(DTower, DTSpawn[lvlUnlockD].position, Quaternion.identity);
                lvlUnlockD += 1;
                purchaseSound.Play();

                //Changes the minimum amount of carrots needed to unlock the next upgrade
                CarrotScore.carrotScore -= minCarNeededD;
                switch (lvlUnlockD)
                {
                case 1:
                    minCarNeededD = 100;
                    break;

                case 2:
                    minCarNeededD = 150;
                    break;

                case 3:
                    minCarNeededD = 200;
                    break;

                default:
                    break;
                }

                //The initiates the void function in the CarrotScore script
                CarrotScore.UpdateCarrotScore();
                DTCost.UpdateDTCost();
                if (lvlUnlockD >= 4)
                {
                    dtBought = true;
                }
            }
        }
        if (dtBought == true)
        {
            costText.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 4
0
    void Update()
    {
        if (pBuyingC && Input.GetKeyDown(KeyCode.E))
        {
            //This allows the player to unlock higher upgrade levels when a minimum amount of
            //carrots has been met
            if (CarrotScore.carrotScore >= minCarNeededC && lvlUnlockC <= 3)
            {
                //Spawns the carrot prefab in a position equal to the lvlUnlock and increases
                //the lvlUnlock
                Instantiate(cPrefabC, cSpawnC[lvlUnlockC].position, Quaternion.identity);
                lvlUnlockC += 1;
                purchaseSound.Play();

                //Changes the minimum amount of carrots needed to unlock the next upgrade
                CarrotScore.carrotScore -= minCarNeededC;
                switch (lvlUnlockC)
                {
                case 1:
                    minCarNeededC = 100;
                    break;

                case 2:
                    minCarNeededC = 200;
                    break;

                case 3:
                    minCarNeededC = 400;
                    break;

                default:
                    break;
                }

                //The initiates the void function in the CarrotScore script
                CarrotScore.UpdateCarrotScore();
                CarSCost.UpdateCSCost();
                if (lvlUnlockC >= 4)
                {
                    csBought = true;
                }
            }
        }

        if (csBought == true)
        {
            costText.gameObject.SetActive(false);
        }
    }