Exemplo n.º 1
0
    void OnBuy(GameObject obj)
    {
        PaperShop pp = obj.GetComponent <UISlotShopGood>().datapaper;

        GameData.lstPaper.Add(pp);

        Item it = DataCenter.Instance.dictItem[pp.Price[0].strId];

        // 钱
        if (it.ID == "1")
        {
            GameData.Coins -= pp.Price[0].nCount;
        }
        //水晶
        else if (it.ID == "2")
        {
            GameData.Gems -= pp.Price[0].nCount;
        }


        GameObject.Destroy(obj);

        // 刷新能不能买
        for (int i = 0; i < trsGoodListRoot.childCount; i++)
        {
            GameObject objaa = trsGoodListRoot.GetChild(i).gameObject;

            objaa.GetComponent <UISlotShopGood>().UpdateSlotInfo(objaa.GetComponent <UISlotShopGood>().datapaper);
        }

        UIPanelManager.Instance.GetPanel("UIGameHUD").Repaint();
    }
Exemplo n.º 2
0
    public void UpdateSlotInfo(PaperShop paper)
    {
        datapaper = paper;

        imgIcon.sprite = paper.IconSprite;

        Item it = DataCenter.Instance.dictItem[datapaper.Price[0].strId];

        imgPrice.sprite = it.IconSprite;
        txtPrice.text   = datapaper.Price[0].nCount.ToString();

        bool CanBuy = false;

        // 钱
        if (it.ID == "1")
        {
            if (GameData.Coins >= datapaper.Price[0].nCount)
            {
                CanBuy = true;
            }
        }
        //水晶
        else if (it.ID == "2")
        {
            if (GameData.Gems >= datapaper.Price[0].nCount)
            {
                CanBuy = true;
            }
        }


        btBuy.GetComponent <Button>().interactable = CanBuy;
    }