コード例 #1
0
    public void HeartPerClickUpgrade()
    {
        if (HeartButtonDisabled == false)
        {
            HeartUpgrade[TotalHeartClicks - 1].GetComponent <Image>().color = new Color32(254, 192, 8, 255);
            TotalHeartClicks += 1;


            if (TotalCoinsVariable >= HeartFirstUpgrade && HeartFirstUpgradeBool == 0)
            {
                HeartFirstUpgradeBool = 1;
                PlayerPrefs.SetInt("HeartFirstUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - HeartFirstUpgrade);
                PlayerPrefs.SetInt("DefaultMaxHP", 4);
                HeartCost.text = HeartSecondUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= HeartSecondUpgrade && HeartSecondUpgradeBool == 0 && HeartFirstUpgradeBool == 1)
            {
                HeartSecondUpgradeBool = 1;
                PlayerPrefs.SetInt("HeartSecondUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - HeartSecondUpgrade);
                PlayerPrefs.SetInt("DefaultMaxHP", 5);
                HeartCost.text = HeartThirdUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= HeartThirdUpgrade && HeartThirdUpgradeBool == 0 && HeartSecondUpgradeBool == 1)
            {
                HeartThirdUpgradeBool = 1;
                PlayerPrefs.SetInt("HeartThirdUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - HeartThirdUpgrade);
                PlayerPrefs.SetInt("DefaultMaxHP", 6);
                HeartCost.text = HeartFourthUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= HeartFourthUpgrade && HeartFourthUpgradeBool == 0 && HeartThirdUpgradeBool == 1)
            {
                HeartFourthUpgradeBool = 1;
                PlayerPrefs.SetInt("HeartFourthUpgradeBool", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - HeartFourthUpgrade);
                PlayerPrefs.SetInt("DefaultMaxHP", 7);
                HeartCost.text = HeartFifthUpgrade.ToString();
            }

            else if (TotalCoinsVariable >= HeartFifthUpgrade && HeartFifthUpgradeBool == 0 && HeartFourthUpgradeBool == 1)
            {
                HeartFifthUpgradeBool = 1;
                PlayerPrefs.SetInt("HeartFifthUpgradeBool", 1);
                PlayerPrefs.SetInt("HeartMaxUpgrade", 1);
                PlayerPrefs.SetInt("Coins", TotalCoinsVariable - HeartFifthUpgrade);
                PlayerPrefs.SetInt("DefaultMaxHP", 8);
            }
            else
            {
                HeartButtonDisabled = true;
            }
        }
    }
コード例 #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);
        }
    }