Ejemplo n.º 1
0
    public void updateItemsThatCanBeProducedList()
    {
        if (gameManager.getBuildingCatalog().getBuildingLastClicked())
        {
            buildingAttributes = gameManager.getBuildingCatalog().getBuildingLastClicked().GetComponent <BuildingAttributes>();
        }

        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }
        if (buildingAttributes)
        {
            foreach (var item in buildingAttributes.getItemsProducedInBuilding())
            {
                GameObject newButton = Instantiate(itemButton, transform);
                newButton.GetComponentInChildren <Text>().text = item.Key;
                newButton.GetComponent <SelectItemButton>().setItem(item.Key);


                if (gameManager.getItemCatalog().getSelectedItem() != null)
                {
                    if (gameManager.getItemCatalog().getSelectedItem().getName() == item.Key)
                    {
                        Button     button = newButton.GetComponent <Button>();
                        ColorBlock block  = button.colors;
                        block.normalColor = Color.green; //new Color(159, 12, 255);
                        button.colors     = block;
                    }
                    else
                    {
                        Button     button = newButton.GetComponent <Button>();
                        ColorBlock block  = button.colors;
                        block.normalColor = new Color(255, 255, 255);
                        button.colors     = block;
                    }
                }
            }
        }
    }