Beispiel #1
0
    private void OnMouseUpAsButton()
    {
        string state;

        if (gameObject == tnt)
        {
            state = SPlayerPrefs.GetString(STATEITEM + direct);
            if (state == "Buy")
            {
                Debug.Log("pez " + direct);
                money = SPlayerPrefs.GetInt("Money");
                if (money >= priceItem[direct])
                {
                    money -= priceItem[direct];
                    SPlayerPrefs.SetInt("Money", money);
                    SPlayerPrefs.SetString(STATEITEM + direct, "Buyed");
                    SPlayerPrefs.Save();
                    textButton.GetComponent <Text>().text = "Buyed";
                }
            }
        }
        else
        {
            //gameObject.GetComponent<Image>().color = Color.red;
            direct = itemCount;
            state  = SPlayerPrefs.GetString(STATEITEM + itemCount);
            Debug.Log(state);
            if (state == "Buyed")
            {
                for (int i = 0; i < priceItem.Length; i++)
                {
                    if (SPlayerPrefs.GetString(STATEITEM + i) == "Selected")
                    {
                        SPlayerPrefs.SetString(STATEITEM + i, "Buyed");
                        break;
                    }
                }
                SPlayerPrefs.SetString(STATEITEM + itemCount, "Selected");
                SPlayerPrefs.SetInt("DigitStateItemIsSelected", itemCount);
                SPlayerPrefs.Save();
                textButton.GetComponent <Text>().text = "Selected";
            }
            else if (state == "Selected")
            {
                textButton.GetComponent <Text>().text = "Selected";
            }
            else if (state == "Buy")
            {
                textButton.GetComponent <Text>().text = "Buy " + priceItem[itemCount];
            }
            Debug.Log("post" + state);
        }
    }
Beispiel #2
0
    private void Update()
    {
        if (gameObject != tnt)
        {
            string state = SPlayerPrefs.GetString(STATEITEM + itemCount);
            switch (state)
            {
            case "Selected":
                visualStateLock.SetActive(false);
                visualStateSelected.SetActive(true);
                break;

            case "Buyed":
                visualStateLock.SetActive(false);
                visualStateSelected.SetActive(false);
                break;

            case "Buy":
                visualStateSelected.SetActive(false);
                visualStateLock.SetActive(true);
                break;
            }
        }
    }