Пример #1
0
    private void FillShop()
    {
        for (int i = 0; i < shopItem.Length; i++)
        {
            ShopItemScriptObj si = shopItem[i];
            itemObject = Instantiate(shopItemPrefab, shopContainer);

            itemObject.GetComponent <Button>().onClick.AddListener(() => OnButtonClick(si));
            itemObject.GetComponent <Image>().color = si.itemColor;
            itemObject.transform.GetChild(1).GetComponent <Text>().text = "$ " + si.itemPrice.ToString();
            itemObject.GetComponent <ShopItem>().SetScriptObj(si);
        }
    }
Пример #2
0
 private void OnButtonClick(ShopItemScriptObj item)
 {
     if (Player.balancePerm >= item.itemPrice && Player.balancePerm >= 0 && !item.itemIsOwned)
     {
         if (!item.itemIsOwned)
         {
             Player.balancePerm -= item.itemPrice;
             PlayerPrefs.SetInt("balancePerm", Player.balancePerm);
             balancePermText.text = Player.balancePerm.ToString();
         }
         PlayerColorCarrier.instance.playerColor = item.itemColor;
         item.itemIsOwned = true;
     }
     else
     {
         PlayerColorCarrier.instance.playerColor = item.itemColor;
         print("Already Bought or not enough balance");
     }
 }
Пример #3
0
 public void SetScriptObj(ShopItemScriptObj scriptObj)
 {
     shopItemScriptObj = scriptObj;
 }