Beispiel #1
0
    private void DrawSelected()
    {
        BlueprintDesign   bd = GetSelectedBlueprintDesign();
        StructureReusable sr = GetStructureReusable(selectedRect, bd);

        sr.Draw(selectedRect, true);
    }
Beispiel #2
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);
    }
    public StructureReusable(Rect drawRect, Texture iconTexture, string title, BlueprintDesign blueprintDesign)
    {
        igrList = new List <IconGroupReusable>();
        labels  = new List <string>();

        this.iconTexture     = iconTexture;
        this.title           = title;
        this.blueprintDesign = blueprintDesign;

        titleStyle           = GUIFunctions.GetStandardGUIStyle(12);
        titleStyle.alignment = TextAnchor.MiddleCenter;
        labelStyle           = GUIFunctions.GetStandardGUIStyle(8);
        labelStyle.alignment = TextAnchor.MiddleLeft;

        titleHeight = titleStyle.CalcSize(new GUIContent("HEIGHT LAWL")).y;

        float iconSize = drawRect.height - titleHeight;

        iconRect  = new Rect(0, 0, iconSize, iconSize);
        titleRect = new Rect(0, 0, drawRect.width, titleHeight);
        listRect  = new Rect(iconRect.width, titleHeight, drawRect.width, iconRect.height);

        background = GUIFunctions.Get1x1Texture(new Color(0f, 1f, 1f, 0.5f));

        BuildIGRList();
    }
Beispiel #4
0
 public BlueprintDesign GetBlueprintDesign()
 {
     if (blueprintDesign == null)
     {
         blueprintDesign = BlueprintDesignManager.GetDefaultDesign(thingType);
     }
     return(blueprintDesign);
 }
Beispiel #5
0
 private StructureReusable GetStructureReusable(Rect drawRect, BlueprintDesign blueprintDesign)
 {
     if (!structureReusables.ContainsKey(blueprintDesign))
     {
         Thing             thing = ThingFactory.MakeThing(blueprintDesign.thingType);
         StructureReusable sr    = new StructureReusable(drawRect, thing.iconTexture, thing.longName, blueprintDesign);
         structureReusables.Add(blueprintDesign, sr);
     }
     return(structureReusables[blueprintDesign]);
 }
    public static BlueprintDesign GetDefaultDesign(ThingTypes thingType)
    {
        if (thingTypeDesigns.ContainsKey(thingType))
        {
            return(thingTypeDesigns[thingType]);
        }

        BlueprintDesign bd = new BlueprintDesign();

        bd.thingType = thingType;
        AddBuildRequirements(bd);

        if (!bd.IsSet())
        {
            Debug.LogError("GetDefaultDesign did not set the BlueprintDesign at all for: " + thingType);
        }

        blueprintDesigns.Add(bd);
        thingTypeDesigns.Add(thingType, bd);
        return(bd);
    }
    private static void AddBuildRequirements(BlueprintDesign bd)
    {
        if (bd.thingType == ThingTypes.awg)
        {
            bd.AddThing(ThingTypes.compressor, 1, 1);
            bd.AddThing(ThingTypes.condenser, 1, 1);
            bd.AddThing(ThingTypes.evaporator, 1, 1);
            bd.AddThing(ThingTypes.glass, 6, 1);
            bd.AddThing(ThingTypes.propeller, 1, 2);
            bd.AddThing(ThingTypes.pump, 1, 1);
            bd.AddThing(ThingTypes.iron, 2, 2, "tank");
            bd.AddThing(ThingTypes.rubbertube, 4, 1);
            bd.AddThing(ThingTypes.valve, 1, 2);

            bd.AddTool(ThingTypes.greasegun, 15, 2, "propeller");
            bd.AddTool(ThingTypes.wrench, 5, 2, "valve");
        }
        else if (bd.thingType == ThingTypes.windturbine)
        {
            bd.AddThing(ThingTypes.mppt, 1, 1);
            bd.AddThing(ThingTypes.turbineblade, 1, 1);
            bd.AddThing(ThingTypes.powercable, 4, 1);

            bd.AddThing(ThingTypes.steel, 2, 1, "frame");

            bd.AddTool(ThingTypes.shovel, 40, 1, "cement-base");
            bd.AddThing(ThingTypes.martiancement, 4, 1, "cement-base");

            bd.AddTool(ThingTypes.wirecutters, 5, 1, "power-cable");
            bd.AddTool(ThingTypes.greasegun, 10, 1, "hub");
        }
        else if (bd.thingType == ThingTypes.solarpanel)
        {
            bd.AddThing(ThingTypes.mppt, 1, 1);
            bd.AddThing(ThingTypes.solarcell, 1, 4);
            bd.AddThing(ThingTypes.powercable, 1, 1);

            bd.AddThing(ThingTypes.steel, 1, 1, "supports");
            bd.AddTool(ThingTypes.wirecutters, 5, 1, "power-cable");
        }
        else if (bd.thingType == ThingTypes.chargingstation)
        {
            bd.AddThing(ThingTypes.lithiumbattery, 12, 1, "batteries");
            bd.AddThing(ThingTypes.powercable, 1, 1, "cable-big");
            bd.AddThing(ThingTypes.powercable, 5, 1, "cables");
            bd.AddTool(ThingTypes.wirecutters, 25, 1, "cables");
        }
        else if (bd.thingType == ThingTypes.plasticdome)
        {
            foreach (Vector3 point in GetPointsOnCircle(20, 8, 1))
            {
                bd.AddThing(ThingTypes.plasticsheet, 5, point);
            }
        }
        else if (bd.thingType == ThingTypes.tanksmall || bd.thingType == ThingTypes.tanklarge)
        {
            float multiplier = bd.thingType == ThingTypes.tanksmall ? 1 : 5;
            foreach (Vector3 point in GetPointsOnCircle(2 * multiplier, 6, 1))
            {
                bd.AddThing(ThingTypes.iron, 1, point);
            }
            bd.AddThing(ThingTypes.valve, 1, 1);
            bd.AddTool(ThingTypes.wrench, 15 * multiplier, 1, "valve");
        }
        else if (bd.thingType == ThingTypes.oxygencrate)
        {
            bd.AddThing(ThingTypes.iron, 3, 1, "cage");
            bd.AddThing(ThingTypes.iron, 9, 1, "tank");
            bd.AddThing(ThingTypes.valve, 9, 1);
            bd.AddTool(ThingTypes.wrench, 30, 1, "valve");
        }
        else if (bd.thingType == ThingTypes.lithiumcrate)
        {
            bd.AddThing(ThingTypes.iron, 3, 1, "cage");
            bd.AddThing(ThingTypes.lithiumbattery, 8, 1, "battery");
            bd.AddTool(ThingTypes.wirecutters, 25, 1, "display");
        }
        else if (bd.thingType == ThingTypes.flyRoverWheel)
        {
            bd.AddThing(ThingTypes.steel, 3, 1, "cylinder");
            bd.AddThing(ThingTypes.steel, 3, 1, "top");
            bd.AddTool(ThingTypes.wirecutters, 1, 1, "frame");
            bd.AddTool(ThingTypes.solderinggun, 15, 1, "top");
        }
    }
Beispiel #8
0
    private Thing GetSelectedBlueprintThing()
    {
        BlueprintDesign bd = Toolbar.GetBlueprintWindow().GetSelectedBlueprintDesign();

        return(ThingFactory.MakeThing(bd.thingType));
    }