Example #1
0
    public void BulletPerClickUpgrade()
    {
        if (BulletButtonDisabled == false)
        {
            BulletUpgrade[TotalBulletClicks - 1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            TotalBulletClicks += 1;


            if (TotalCoinsVariable >= BulletFirstUpgrade && BulletFirstUpgradeBool == 0)
            {
                BulletFirstUpgradeBool = 1;
                PlayerPrefs.SetInt("BulletFirstUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - BulletFirstUpgrade);
                PlayerPrefs.SetFloat("TimeBetweenShotDefault", 1.0f);
                BulletCost.text = BulletFirstUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= BulletSecondUpgrade && BulletSecondUpgradeBool == 0 && BulletFirstUpgradeBool == 1)
            {
                BulletSecondUpgradeBool = 1;
                PlayerPrefs.SetInt("BulletSecondUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - BulletSecondUpgrade);
                PlayerPrefs.SetFloat("TimeBetweenShotDefault", 0.9f);
                BulletCost.text = BulletSecondUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= BulletThirdUpgrade && BulletThirdUpgradeBool == 0 && BulletSecondUpgradeBool == 1)
            {
                BulletThirdUpgradeBool = 1;
                PlayerPrefs.SetInt("BulletThirdUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - BulletThirdUpgrade);
                PlayerPrefs.SetFloat("TimeBetweenShotDefault", 0.85f);
                BulletCost.text = BulletThirdUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= BulletFourthUpgrade && BulletFourthUpgradeBool == 0 && BulletThirdUpgradeBool == 1)
            {
                BulletFourthUpgradeBool = 1;
                PlayerPrefs.SetInt("BulletFourthUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - BulletFourthUpgrade);
                PlayerPrefs.SetFloat("TimeBetweenShotDefault", 0.8f);
                BulletCost.text = BulletFourthUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= BulletFifthUpgrade && BulletFifthUpgradeBool == 0 && BulletFourthUpgradeBool == 1)
            {
                BulletFifthUpgradeBool = 1;
                PlayerPrefs.SetInt("BulletFifthUpgradeBool", 1);
                PlayerPrefs.SetInt("BulletMaxUpgrade", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - BulletFifthUpgrade);
                PlayerPrefs.SetFloat("TimeBetweenShotDefault", 0.75f);
            }
            else
            {
                BulletButtonDisabled = true;
            }
        }
    }
Example #2
0
    private void Update()
    {
        TotalCoinsVariable = PlayerPrefs.GetInt("Coins");
        TotalCoins.text    = TotalCoinsVariable.ToString();

        HeartMaxUpgrade  = PlayerPrefs.GetInt("HeartMaxUpgrade");
        BulletMaxUpgrade = PlayerPrefs.GetInt("BulletMaxUpgrade");
        CoinMaxUpgrade   = PlayerPrefs.GetInt("CoinMaxUpgrade");

        HeartFirstUpgradeBool  = PlayerPrefs.GetInt("HeartFirstUpgradeBool");
        HeartSecondUpgradeBool = PlayerPrefs.GetInt("HeartSecondUpgradeBool");
        HeartThirdUpgradeBool  = PlayerPrefs.GetInt("HeartThirdUpgradeBool");
        HeartFourthUpgradeBool = PlayerPrefs.GetInt("HeartFourthUpgradeBool");
        HeartFifthUpgradeBool  = PlayerPrefs.GetInt("HeartFifthUpgradeBool");

        BulletFirstUpgradeBool  = PlayerPrefs.GetInt("BulletFirstUpgradeBool");
        BulletSecondUpgradeBool = PlayerPrefs.GetInt("BulletSecondUpgradeBool");
        BulletThirdUpgradeBool  = PlayerPrefs.GetInt("BulletThirdUpgradeBool");
        BulletFourthUpgradeBool = PlayerPrefs.GetInt("BulletFourthUpgradeBool");
        BulletFifthUpgradeBool  = PlayerPrefs.GetInt("BulletFifthUpgradeBool");

        CoinFirstUpgradeBool  = PlayerPrefs.GetInt("CoinFirstUpgradeBool");
        CoinSecondUpgradeBool = PlayerPrefs.GetInt("CoinSecondUpgradeBool");
        CoinThirdUpgradeBool  = PlayerPrefs.GetInt("CoinThirdUpgradeBool");
        CoinFourthUpgradeBool = PlayerPrefs.GetInt("CoinFourthUpgradeBool");
        CoinFifthUpgradeBool  = PlayerPrefs.GetInt("CoinFifthUpgradeBool");

        if (HeartFirstUpgradeBool == 1)
        {
            HeartUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartCost.text = HeartSecondUpgrade.ToString();
        }
        if (HeartSecondUpgradeBool == 1)
        {
            HeartUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartCost.text = HeartThirdUpgrade.ToString();
        }
        if (HeartThirdUpgradeBool == 1)
        {
            HeartUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartCost.text = HeartFourthUpgrade.ToString();
        }
        if (HeartFourthUpgradeBool == 1)
        {
            HeartUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartUpgrade[3].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            HeartCost.text = HeartFifthUpgrade.ToString();
        }

        if (HeartFirstUpgradeBool == 0 && HeartSecondUpgradeBool == 0 && HeartThirdUpgradeBool == 0 && HeartFourthUpgradeBool == 0 && HeartMaxUpgrade == 0)
        {
            for (int i = 0; i < HeartUpgrade.Length; i++)
            {
                HeartUpgrade[i].GetComponent <Image>().color = new Color32(255, 255, 255, 255);
            }
            HeartUpgradeCoin.GetComponent <Image>().enabled = true;
            HeartUpgradeButton.SetActive(true);
            HeartCost.text  = HeartFirstUpgrade.ToString();
            HeartCost.color = new Color32(255, 192, 8, 255);
        }

        if (BulletFirstUpgradeBool == 1)
        {
            BulletUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletCost.text = BulletSecondUpgrade.ToString();
        }
        if (BulletSecondUpgradeBool == 1)
        {
            BulletUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletCost.text = BulletThirdUpgrade.ToString();
        }
        if (BulletThirdUpgradeBool == 1)
        {
            BulletUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletCost.text = BulletFourthUpgrade.ToString();
        }
        if (BulletFourthUpgradeBool == 1)
        {
            BulletUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletUpgrade[3].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            BulletCost.text = BulletFifthUpgrade.ToString();
        }

        if (BulletFirstUpgradeBool == 0 && BulletSecondUpgradeBool == 0 && BulletThirdUpgradeBool == 0 && BulletFourthUpgradeBool == 0 && BulletMaxUpgrade == 0)
        {
            for (int i = 0; i < BulletUpgrade.Length; i++)
            {
                BulletUpgrade[i].GetComponent <Image>().color = new Color32(255, 255, 255, 255);
            }

            BulletUpgradeCoin.GetComponent <Image>().enabled = true;
            BulletUpgradeButton.SetActive(true);
            BulletCost.text  = BulletFirstUpgrade.ToString();
            BulletCost.color = new Color32(255, 192, 8, 255);
        }

        if (CoinFirstUpgradeBool == 1)
        {
            CoinUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinCost.text = CoinSecondUpgrade.ToString();
        }
        if (CoinSecondUpgradeBool == 1)
        {
            CoinUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinCost.text = CoinThirdUpgrade.ToString();
        }
        if (CoinThirdUpgradeBool == 1)
        {
            CoinUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinCost.text = CoinFourthUpgrade.ToString();
        }
        if (CoinFourthUpgradeBool == 1)
        {
            CoinUpgrade[0].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[2].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinUpgrade[3].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            CoinCost.text = CoinFifthUpgrade.ToString();
        }

        if (CoinFirstUpgradeBool == 0 && CoinSecondUpgradeBool == 0 && CoinThirdUpgradeBool == 0 && CoinFourthUpgradeBool == 0 && CoinMaxUpgrade == 0)
        {
            for (int i = 0; i < CoinUpgrade.Length; i++)
            {
                CoinUpgrade[i].GetComponent <Image>().color = new Color32(255, 255, 255, 255);
            }

            CoinUpgradeCoin.GetComponent <Image>().enabled = true;
            CoinUpgradeButton.SetActive(true);
            CoinCost.text  = CoinFirstUpgrade.ToString();
            CoinCost.color = new Color32(255, 192, 8, 255);
        }

        if (TotalCoinsVariable >= HeartFirstUpgrade || TotalCoinsVariable >= HeartSecondUpgrade || TotalCoinsVariable >= HeartThirdUpgrade || TotalCoinsVariable >= HeartFourthUpgrade || TotalCoinsVariable >= HeartFifthUpgrade)
        {
            HeartCost.color = new Color32(254, 192, 8, 255);
        }
        else
        {
            HeartCost.color = new Color32(255, 0, 0, 255);
        }
        if (TotalCoinsVariable >= BulletFirstUpgrade || TotalCoinsVariable >= BulletSecondUpgrade || TotalCoinsVariable >= BulletThirdUpgrade || TotalCoinsVariable >= BulletFourthUpgrade || TotalCoinsVariable >= BulletFifthUpgrade)
        {
            BulletCost.color = new Color32(254, 192, 8, 255);
        }
        else
        {
            BulletCost.color = new Color32(255, 0, 0, 255);
        }
        if (TotalCoinsVariable >= CoinFirstUpgrade || TotalCoinsVariable >= CoinSecondUpgrade || TotalCoinsVariable >= CoinThirdUpgrade || TotalCoinsVariable >= CoinFourthUpgrade || TotalCoinsVariable >= CoinFifthUpgrade)
        {
            CoinCost.color = new Color32(254, 192, 8, 255);
        }
        else
        {
            CoinCost.color = new Color32(255, 0, 0, 255);
        }
        if (HeartMaxUpgrade == 1)
        {
            TotalHeartClicks = 1;
            for (int i = 0; i < HeartUpgrade.Length; i++)
            {
                HeartUpgrade[i].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            }
            HeartUpgradeCoin.GetComponent <Image>().enabled = false;
            HeartUpgradeButton.SetActive(false);
            HeartCost.text  = "MAX";
            HeartCost.color = new Color32(255, 0, 0, 255);
        }

        if (BulletMaxUpgrade == 1)
        {
            TotalBulletClicks = 1;
            for (int i = 0; i < BulletUpgrade.Length; i++)
            {
                BulletUpgrade[i].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            }
            BulletUpgradeCoin.GetComponent <Image>().enabled = false;
            BulletUpgradeButton.SetActive(false);
            BulletCost.text  = "MAX";
            BulletCost.color = new Color32(255, 0, 0, 255);
        }
        if (CoinMaxUpgrade == 1)
        {
            TotalCoinClicks = 1;
            for (int i = 0; i < CoinUpgrade.Length; i++)
            {
                CoinUpgrade[i].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            }
            CoinUpgradeCoin.GetComponent <Image>().enabled = false;
            CoinUpgradeButton.SetActive(false);
            CoinCost.text  = "MAX";
            CoinCost.color = new Color32(255, 0, 0, 255);
        }
    }