protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            //Draw the back first
            Color backColor = new Color()
            {
                PackedValue = 0xff4c5452
            };

            var texture = ModContent.GetTexture("TerraScience/Content/UI/fluidgauge back");
            var dims    = GetInnerDimensions();

            spriteBatch.Draw(texture, dims.Position(), null, backColor);

            int       visibleHeight = texture.Height - 12;
            float     height        = visibleHeight - visibleHeight * fluidCur / fluidMax;
            Rectangle source        = new Rectangle(0, 6 + (int)height, texture.Width, texture.Height - (int)height - 6);

            if (fluidColor != Color.Transparent)
            {
                spriteBatch.Draw(texture, dims.Position() + new Vector2(0, 6 + height), source, fluidColor);
            }

            var textureFrame = ModContent.GetTexture("TerraScience/Content/UI/fluidgauge border");

            spriteBatch.Draw(textureFrame, dims.Position(), null, Color.White);

            //Why does this have to be in Draw and not Update?  The world will never know...
            if (ContainsPoint(Main.MouseScreen) && fluidName != null)
            {
                Main.hoverItemName = $"{fluidName}: {MachineUI.UIDecimalFormat(fluidCur)} / {MachineUI.UIDecimalFormat(fluidMax)} L";
            }
        }
Example #2
0
    void Awake()
    {
        instance = this;
        GameObject toolBoxPanel = gameObject.transform.GetChild(0).gameObject;

        toolBoxPanel.SetActive(true);
        runControls = gameObject.transform.GetChild(1).GetComponent <RunUI>();
        machines    = gameObject.transform.GetChild(2).GetComponent <MachineUI>();
        select      = gameObject.transform.GetChild(3).GetComponent <SelectUI>();
    }
 public static int GetIconType(this MachineUI ui) => TechMod.Instance.ItemType(ui.MachineName + "Item");
Example #4
0
    // Start is called before the first frame update
    void Start()
    {
        filterMining = new ContactFilter2D();
        filterMining.useLayerMask = true;
        filterMining.layerMask    = layerMaskMining;
        filterMining.useTriggers  = true;

        filter = new ContactFilter2D();
        filter.useLayerMask = true;
        filter.layerMask    = layerMask;
        filter.useTriggers  = false;

        placeSprite = Instantiate(placeSpritePrefab, Vector3.zero, Quaternion.identity);
        Inventory[] inventories = GetComponents <Inventory>();
        for (int i = 0; i < inventories.Length; i++)
        {
            if (inventories[i] is AmmoSlot)
            {
                ammoInventory = inventories[i] as AmmoSlot;
            }
            else
            {
                playerInventory = inventories[i];
            }
        }

        playerInventory     = GetComponent <Inventory>();
        placeSpriteRenderer = placeSprite.GetComponent <SpriteRenderer>();
        Camera.main.GetComponent <CameraFollow>().SetCameraTarget(this.gameObject);

        placeGrid            = GameObject.FindGameObjectWithTag("Grid").GetComponent <Grid>();
        canvas               = GameObject.Find("Canvas");
        machinePanelInteract = Instantiate(machinePanelInteractPrefab, canvas.transform);
        inventoryInteract    = Instantiate(inventoryPanelInteractPrefab, canvas.transform);
        inventoryPanel       = Instantiate(inventoryPanelPrefab, canvas.transform);
        craftingPanel        = Instantiate(craftingPanelPrefab, canvas.transform);
        inventoryAmmo        = Instantiate(ammoInventoryPrefab, canvas.transform);
        mouseInventoryUI     = Instantiate(mouseInventoryPrefab, canvas.transform);
        tooltip              = Instantiate(tooltipPanelPrefab, canvas.transform);
        filterItemPanel      = Instantiate(filterItemPanelPrefab, canvas.transform);

        mouseInventoryUI.GetComponent <InventoryMouse>().SetInventory(mouseInventory);
        machineUI           = machinePanelInteract.GetComponentInChildren <MachineUI>();
        inventoryInteractUI = inventoryInteract.GetComponentInChildren <InventoryUI>();
        inventoryUI         = inventoryPanel.GetComponentInChildren <InventoryUI>();
        craftingUI          = craftingPanel.GetComponentInChildren <CraftingUI>();
        inventoryAmmoUI     = inventoryAmmo.GetComponentInChildren <InventoryUI>();
        ammoSlotSelected    = inventoryAmmo.GetComponentInChildren <HighlightSlotUI>();
        filterItemUI        = filterItemPanel.GetComponent <UIFilterItem>();

        inventoryAmmoUI.SetViewedInventory(ammoInventory);
        inventoryAmmoUI.SetMouseInventory(mouseInventory);
        inventoryUI.SetViewedInventory(playerInventory);
        inventoryUI.SetMouseInventory(mouseInventory);
        inventoryInteractUI.SetMouseInventory(mouseInventory);
        craftingUI.SetLinkedInventory(playerInventory);
        machineUI.SetMouseInventory(mouseInventory);



        characterAlliance = AllianceDefinitions.Instance.GetAlliance("Character");
        this.gameObject.GetComponent <Health>().alliance = characterAlliance.allianceCode;
    }
Example #5
0
 public void GenerateMachineUI()
 {
     machineUI = Resources.Load <MachineUI>("UIs/Machines/" + blockId);
 }