Beispiel #1
0
        public MenuComponent CreateMachineInterface(Machine machine, Player player, RecipeCollection recipeCollection)
        {
            Font          menuFont        = fontContainer.GetFont("SairaRegular");
            MenuPanel     machinePanel    = new MenuPanel(new Vector2i(0, 0), new Vector2i(500, 200), new FloatRect(0, 0, 96, 96), 8, null, new Color(255, 255, 255, 224));
            MenuInventory inputInventory  = new MenuInventory(new Vector2i(96, 64), machine.input, player, machine, menuFont);
            MenuInventory outputInventory = new MenuInventory(new Vector2i(96, 64), machine.result, player, machine, menuFont);

            outputInventory.allowInsertion = false;
            MenuProgressBar recipeProgress = new MenuProgressBar(new Vector2i(128, 16), new FloatRect(0, 0, 32, 32), new FloatRect(0, 0, 32, 32), machine.GetProgress, new Color(196, 92, 0));
            MenuDrawable    machineGraphic = new MenuDrawable(new Vector2i(128, 128), machine, 0);

            Recipe[]  recipes     = recipeCollection.GetRecipes(new string[] { machine.name });
            MenuPanel recipePanel = CreateRecipePanel(machine.ApplyRecipe, player, recipes);

            machinePanel.AttachComponent(recipePanel);
            recipePanel.SetPivots("right", "center", "outside", 0);
            recipePanel.SetInitialPosition(machinePanel);
            recipePanel.lockedPosition = true;
            machinePanel.AttachComponent(inputInventory);
            machinePanel.AttachComponent(recipeProgress);
            machinePanel.AttachComponent(outputInventory);
            machinePanel.AttachComponent(machineGraphic);
            inputInventory.SetInitialPosition();
            recipeProgress.SetPivots("right", "center", "outside", 0);
            recipeProgress.SetInitialPosition(inputInventory);
            outputInventory.SetPivots("right", "center", "outside", 0);
            outputInventory.SetInitialPosition(inputInventory);
            menuContainer.AttachMenu(machinePanel);
            machinePanel.closePanelKey = InputBindings.showInventory;
            menuContainer.ClosePanelsWithTag("EntityGUI");
            machinePanel.panelTag = "EntityGUI";
            machinePanel.SetInitialPosition(camera.GetGUIView());

            return(machinePanel);
        }
Beispiel #2
0
        public MenuComponent CreatePlayerProgressBar(Camera camera, Player player, string tag, Color color, MenuComponent relativeComponent)
        {
            MenuProgressBar progressBar = new MenuProgressBar(new Vector2i(512, 16), new FloatRect(0, 0, 32, 32), new FloatRect(0, 0, 32, 32), player.GetProgress, color);

            progressBar.tag = tag;
            if (relativeComponent == null)
            {
                progressBar.SetPivots("center", "bottom", "inside", 8);
                progressBar.SetInitialPosition(camera.GetGUIView());
            }
            progressBar.hideWhenEmpty = true;
            progressBar.hideWhenFull  = true;
            menuContainer.AttachMenu(progressBar);
            return(progressBar);
        }