Exemplo n.º 1
0
    public static IconGroupReusable GetResourcesIconGroupReusable(BlueprintDesign blueprintDesign, bool alwaysUseTextNumbers)
    {
        StructureInfo     structureInfo = new StructureInfo(blueprintDesign.thingType);
        IconGroupReusable igr           = new IconGroupReusable(alwaysUseTextNumbers);

        foreach (ResourceTypes resourceType in System.Enum.GetValues(typeof(ResourceTypes)))
        {
            //consume or produce resources
            int iconCount           = structureInfo.GetInfoIconCount(resourceType, StructureInfo.InfoTypes.optimum);
            IconBackgroundTypes ibt = iconCount < 0 ? IconBackgroundTypes.bar : IconBackgroundTypes.circle;
            if (iconCount != 0)
            {
                Texture backgroundTexture = IconGroupReusable.GetIconBackgroundTexture(ibt);
                Texture texture           = ResourceReusable.GetResourceTextureFromResourceType(resourceType);
                igr.AddIcons(texture, backgroundTexture, Mathf.Abs(iconCount));
            }

            //capacity resources
            iconCount = structureInfo.GetInfoIconCount(resourceType, StructureInfo.InfoTypes.capacity);
            if (iconCount > 0)
            {
                Texture backgroundTexture = IconGroupReusable.GetIconBackgroundTexture(IconBackgroundTypes.square);
                Texture texture           = ResourceReusable.GetResourceTextureFromResourceType(resourceType);
                igr.AddIcons(texture, backgroundTexture, iconCount);
            }
        }
        return(igr);
    }
Exemplo n.º 2
0
    public static Texture GetIconBackgroundTexture(IconBackgroundTypes ibt)
    {
        if (iconBackgroundTextures == null)
        {
            iconBackgroundTextures = new Dictionary <IconBackgroundTypes, Texture>();
        }
        if (!iconBackgroundTextures.ContainsKey(ibt))
        {
            string filename = "unknown";
            if (ibt == IconBackgroundTypes.circle)
            {
                filename = "circle";
            }
            else if (ibt == IconBackgroundTypes.square)
            {
                filename = "square";
            }
            else if (ibt == IconBackgroundTypes.bar)
            {
                filename = "bar";
            }

            Texture texture = Resources.Load(iconFolder + filename) as Texture;
            if (texture == null)
            {
                Debug.LogError("GetIconBackgroundTexture got null texture. ibt=" + ibt + " filename=" + filename);
            }

            iconBackgroundTextures.Add(ibt, texture);
        }
        return(iconBackgroundTextures[ibt]);
    }