Esempio n. 1
0
        public void SetBlocksColor()
        {
            foreach (Block block in GameManager.instance.systemManager.AllBlocks)
            {
                Color chosenColor = defaultColor;

                foreach (Flag flag in block.activeFlags)
                {
                    if (FlagReader.GetCategory(block.scheme) == CityManager.BuildingType.Habitation)
                    {
                        chosenColor = color.Evaluate(0f);
                    }
                    else if (FlagReader.GetCategory(block.scheme) == CityManager.BuildingType.Occupators)
                    {
                        chosenColor = color.Evaluate(0.5f);
                    }
                    else if (FlagReader.GetCategory(block.scheme) == CityManager.BuildingType.Services)
                    {
                        chosenColor = color.Evaluate(1f);
                    }
                }

                block.overlayVisuals.Activate(chosenColor);
            }
        }
Esempio n. 2
0
    void Start()
    {
        // BOX
        containerMat       = Instantiate(meshRenderers[0].material);
        containerMat.color = FlagReader.GetSchemeColor(linkedBlock.scheme);
        foreach (MeshRenderer mr in meshRenderers)
        {
            mr.material = containerMat;
        }
        oColor = containerMat.color;
        cColor = oColor;

        // ICON MESH PLANE
        iconMat = Instantiate(iconRenderers[0].material);
        foreach (MeshRenderer ic in iconRenderers)
        {
            ic.material = iconMat;
        }
        Sprite    sprite         = GameManager.instance.library.buildingsIcons[(int)FlagReader.GetCategory(linkedBlock.scheme)];
        Texture2D croppedTexture = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height);

        Color[] pixels = sprite.texture.GetPixels
                         (
            (int)sprite.rect.x,
            (int)sprite.rect.y,
            (int)sprite.rect.width,
            (int)sprite.rect.height
                         );

        croppedTexture.SetPixels(pixels);
        croppedTexture.Apply();
        iconMat.mainTexture = croppedTexture;
    }
    private void FillCategories()
    {
        foreach (BlockScheme block in GameManager.instance.library.blocks)
        {
            if (!block.isBuyable)
            {
                continue;
            }

            CityManager.BuildingType category = FlagReader.GetCategory(block);

            if (!categories.ContainsKey(category))
            {
                categories[category] = new List <BlockScheme>();
            }
            categories[category].Add(block);
        }
    }