Exemplo n.º 1
0
    public void CloneItemFurnitureType(List <Sprite> sp, int type)
    {
        for (int i = 0; i < sp.Count; i++)
        {
            //SaveSystem.A_AddFurniture(i, type);
            GameObject clone = Instantiate(item.gameObject, parent);
            clone.name = i.ToString();
            FurnitureData data = clone.AddComponent <FurnitureData>();
            data.id    = i;
            data.type  = type;
            data.price = priceListData[i];
            clone.SetActive(true);
            clone.transform.GetChild(0).GetComponent <Image>().sprite          = sp[i];
            clone.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = priceListData[i].ToString();

            List <Furniture> furnitures = SaveSystem.A_LoadFurniture();
            var furCount = from f in furnitures
                           where f.id == data.id && f.type == data.type
                           select f;

            clone.transform.GetChild(2).GetComponent <Text>().text = furCount.Count() <= 0 ? "" : furCount.Count().ToString();
            if (furCount.Count() >= 1 && (type == (int)FurnitureType.Wallpaper || type == (int)FurnitureType.Floor))
            {
                clone.GetComponentInChildren <Button>().interactable = false;
            }
        }
    }