Esempio n. 1
0
    public void Buy()
    {
        if (ItemName == "soda")
        {
            if (BoughtNumber > 0 || soda.sodaBoughtTimes == 1)
            {
                //already have
                if (Text1 != null && Notice1 != null)
                {
                    Text1.GetComponent <Text> ().enabled      = true;
                    Notice1.GetComponent <Image> ().enabled   = true;
                    Notice1.GetComponent <FadeOut> ().enabled = true;
                }
                Debug.Log("you already have one OR bought two times.");
            }
            else
            {
                if (MoneySystem.money >= ItemPrice)
                {
                    MoneySystem.money     = MoneySystem.money - ItemPrice;
                    MoneySystem.MoneyOut  = true;
                    MoneySystem.remainder = MoneySystem.money;
                    SetActiveObject.SetActive(true);
                    SetActiveObject2.SetActive(true);
                    BoughtImage.SetActive(true);
                    BoughtNumber++;
                    save();
                    if (Text3 != null && Notice3 != null)
                    {
                        Text3.GetComponent <Text> ().enabled      = true;
                        Notice3.GetComponent <Image> ().enabled   = true;
                        Notice3.GetComponent <FadeOut> ().enabled = true;
                    }
                    Debug.Log("Buy!");
                }
                else
                {
                    if (Text2 != null && Notice2 != null)
                    {
                        Text2.GetComponent <Text> ().enabled      = true;
                        Notice2.GetComponent <Image> ().enabled   = true;
                        Notice2.GetComponent <FadeOut> ().enabled = true;
                    }
                    //not enough money
                }
            }
        }
        else if (ItemName == "Table" || ItemName == "Cushion" || ItemName == "laundry" || ItemName == "gompang" || ItemName == "mug" || ItemName == "plate" || ItemName == "cake")
        {
            if (BoughtNumber > 0)
            {
                //already have
                if (Text1 != null && Notice1 != null)
                {
                    Text1.GetComponent <Text> ().enabled      = true;
                    Notice1.GetComponent <Image> ().enabled   = true;
                    Notice1.GetComponent <FadeOut> ().enabled = true;
                }
                Debug.Log("you have already one!");
            }
            else
            {
                if (MoneySystem.money >= ItemPrice)
                {
                    MoneySystem.money     = MoneySystem.money - ItemPrice;
                    MoneySystem.MoneyOut  = true;
                    MoneySystem.remainder = MoneySystem.money;
                    SetActiveObject.SetActive(true);
                    SetActiveObject2.SetActive(true);
                    BoughtImage.SetActive(true);
                    BoughtNumber++;
                    save();
                    if (Text3 != null && Notice3 != null)
                    {
                        Text3.GetComponent <Text> ().enabled      = true;
                        Notice3.GetComponent <Image> ().enabled   = true;
                        Notice3.GetComponent <FadeOut> ().enabled = true;
                    }
                    Debug.Log("Buy!");
                }
                else
                {
                    //not enough money
                    if (Text2 != null && Notice2 != null)
                    {
                        Text2.GetComponent <Text> ().enabled      = true;
                        Notice2.GetComponent <Image> ().enabled   = true;
                        Notice2.GetComponent <FadeOut> ().enabled = true;
                    }
                }
            }
        }
        else                    // basic item
        {
            if (MoneySystem.money >= ItemPrice)
            {
                MoneySystem.money    = MoneySystem.money - ItemPrice;
                MoneySystem.MoneyOut = true;
//				MoneySystem.ContentsName = ItemName;
//				MoneySystem.outcome = -ItemPrice;
                MoneySystem.remainder = MoneySystem.money;
                //SetActiveObject.GetComponent<Image> ().enabled = true;
                SetActiveObject.SetActive(true);
                SetActiveObject2.SetActive(true);
                BoughtImage.SetActive(true);
                BoughtNumber++;
                save();
                if (Text3 != null && Notice3 != null)
                {
                    Text3.GetComponent <Text> ().enabled      = true;
                    Notice3.GetComponent <Image> ().enabled   = true;
                    Notice3.GetComponent <FadeOut> ().enabled = true;
                }
                Debug.Log("Buy!");
            }
            else
            {
                //not enough money
                if (Text2 != null && Notice2 != null)
                {
                    Text2.GetComponent <Text> ().enabled      = true;
                    Notice2.GetComponent <Image> ().enabled   = true;
                    Notice2.GetComponent <FadeOut> ().enabled = true;
                }
                Debug.Log("Be short of money");
            }
        }
    }