Example #1
0
    private void CheckPurchasableItems()
    {
        foreach (GameObject item in Items)
        {
            int      Number   = item.GetComponent <ShopItem>().Number;
            ShopItem ShopItem = item.GetComponent <ShopItem>();

            if (!ShopItem.Upgrade && !ShopItem.Skin)
            {
                if (PlayerPrefs.GetInt("Background" + Number.ToString() + "Bought") == 1 &&
                    PlayerPrefs.GetInt("BackgroundSelected") == Number)
                {
                    ShopItem.LockedBtn.SetActive(false);
                    ShopItem.BuyBtn.SetActive(false);
                    ShopItem.MakeActiveBtn.SetActive(false);
                    ShopItem.SelectedBtn.SetActive(true);
                }
                else if (PlayerPrefs.GetInt("Background" + Number.ToString() + "Bought") == 1 &&
                         PlayerPrefs.GetInt("BackgroundSelected") != Number)
                {
                    ShopItem.LockedBtn.SetActive(false);
                    ShopItem.BuyBtn.SetActive(false);
                    ShopItem.MakeActiveBtn.SetActive(true);
                    ShopItem.SelectedBtn.SetActive(false);
                }
                else
                {
                    if (PlayerPrefs.GetInt("TotalBoxCount") >= ShopItem.Cost[0])
                    {
                        ShopItem.LockedBtn.SetActive(false);
                        ShopItem.BuyBtn.SetActive(true);
                        ShopItem.MakeActiveBtn.SetActive(false);
                        ShopItem.SelectedBtn.SetActive(false);
                    }
                    else
                    {
                        ShopItem.LockedBtn.SetActive(true);
                        ShopItem.BuyBtn.SetActive(false);
                        ShopItem.MakeActiveBtn.SetActive(false);
                        ShopItem.SelectedBtn.SetActive(false);
                    }
                }
            }

            if (!ShopItem.Upgrade && !ShopItem.Background)
            {
                if (PlayerPrefs.GetInt("Skin" + Number.ToString() + "Bought") == 1 &&
                    PlayerPrefs.GetInt("SkinSelected") == Number)
                {
                    ShopItem.LockedBtn.SetActive(false);
                    ShopItem.BuyBtn.SetActive(false);
                    ShopItem.MakeActiveBtn.SetActive(false);
                    ShopItem.SelectedBtn.SetActive(true);
                }
                else if (PlayerPrefs.GetInt("Skin" + Number.ToString() + "Bought") == 1 &&
                         PlayerPrefs.GetInt("SkinSelected") != Number)
                {
                    ShopItem.LockedBtn.SetActive(false);
                    ShopItem.BuyBtn.SetActive(false);
                    ShopItem.MakeActiveBtn.SetActive(true);
                    ShopItem.SelectedBtn.SetActive(false);
                }
                else
                {
                    if (PlayerPrefs.GetInt("TotalBoxCount") >= ShopItem.Cost[0])
                    {
                        ShopItem.LockedBtn.SetActive(false);
                        ShopItem.BuyBtn.SetActive(true);
                        ShopItem.MakeActiveBtn.SetActive(false);
                        ShopItem.SelectedBtn.SetActive(false);
                    }
                    else
                    {
                        ShopItem.LockedBtn.SetActive(true);
                        ShopItem.BuyBtn.SetActive(false);
                        ShopItem.MakeActiveBtn.SetActive(false);
                        ShopItem.SelectedBtn.SetActive(false);
                    }
                }
            }

            if (ShopItem.Upgrade)
            {
                if (item.name == "Upgrade Shop Item 0")
                {
                    if (ShopItem.CheckVersion(0) == ShopItem.Cost.Length)
                    {
                        ShopItem.LockedBtn.SetActive(false);
                        ShopItem.BuyBtn.SetActive(false);
                        ShopItem.BoughtBtn.SetActive(true);
                    }
                    else
                    {
                        if (PlayerPrefs.GetInt("TotalBoxCount") >= ShopItem.Cost[ShopItem.CheckVersion(0)])
                        {
                            ShopItem.LockedBtn.SetActive(false);
                            ShopItem.BuyBtn.SetActive(true);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                        else
                        {
                            ShopItem.LockedBtn.SetActive(true);
                            ShopItem.BuyBtn.SetActive(false);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                    }
                }
                else if (item.name == "Upgrade Shop Item 1")
                {
                    if (ShopItem.CheckVersion(1) == ShopItem.Cost.Length)
                    {
                        ShopItem.LockedBtn.SetActive(false);
                        ShopItem.BuyBtn.SetActive(false);
                        ShopItem.BoughtBtn.SetActive(true);
                    }
                    else
                    {
                        if (PlayerPrefs.GetInt("TotalBoxCount") >= ShopItem.Cost[ShopItem.CheckVersion(1)])
                        {
                            ShopItem.LockedBtn.SetActive(false);
                            ShopItem.BuyBtn.SetActive(true);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                        else
                        {
                            ShopItem.LockedBtn.SetActive(true);
                            ShopItem.BuyBtn.SetActive(false);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                    }
                }
                else if (item.name == "Upgrade Shop Item 2")
                {
                    if (ShopItem.CheckVersion(2) == ShopItem.Cost.Length)
                    {
                        ShopItem.LockedBtn.SetActive(false);
                        ShopItem.BuyBtn.SetActive(false);
                        ShopItem.BoughtBtn.SetActive(true);
                    }
                    else
                    {
                        if (PlayerPrefs.GetInt("TotalBoxCount") >= ShopItem.Cost[ShopItem.CheckVersion(2)])
                        {
                            ShopItem.LockedBtn.SetActive(false);
                            ShopItem.BuyBtn.SetActive(true);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                        else
                        {
                            ShopItem.LockedBtn.SetActive(true);
                            ShopItem.BuyBtn.SetActive(false);
                            ShopItem.BoughtBtn.SetActive(false);
                        }
                    }
                }
            }
        }
    }