public CraftingInformationPage(int x, int y, int width, int height, Color BackgroundColor, CraftingRecipeButton ItemToDisplay, ref IList <Item> Inventory, ref IList <Item> OutputInventory, bool IsPlayerInventory, Machine Machine) : base(x, y, width, height, false)
        {
            this.backgroundColor     = BackgroundColor;
            this.infoButton          = ItemToDisplay;
            this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128));
            this.inventory           = Inventory;
            this.isPlayerInventory   = IsPlayerInventory;

            this.requiredItems = new Dictionary <ItemDisplayButton, int>();
            for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++)
            {
                ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64 + this.width, this.yPositionOnScreen + (i * 64) + 128), new Rectangle(0, 0, 64, 64), 2f, true, Color.White);
                this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount);
            }
            this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2 - 96, this.getCraftingButtonHeight()), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"), new StardustCore.Animations.Animation(0, 0, 48, 16)), Color.White), new Rectangle(0, 0, 48, 16), 4f);

            if (OutputInventory == null)
            {
                this.outputInventory = this.inventory;
            }
            if (this.infoButton.recipe.statCost != null)
            {
                if (this.infoButton.recipe.statCost.gold > 0)
                {
                    this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f);
                }
            }
            this.outputInventory = OutputInventory;
            this.machine         = Machine;
        }
 /// <summary>
 /// Adds in a crafting recipe to the crafting menu.
 /// </summary>
 /// <param name="Button"></param>
 /// <param name="WhichTab"></param>
 public void addInCraftingRecipe(CraftingRecipeButton Button, string WhichTab)
 {
     if (this.craftingItemsToDisplay.ContainsKey(WhichTab))
     {
         int     count  = this.craftingItemsToDisplay[WhichTab].Count % this.amountOfRecipesToShow;
         Vector2 newPos = new Vector2(this.xPositionOnScreen + (128), (this.yPositionOnScreen + 64) + (64 * (count + 1)));
         Button.displayItem.Position = newPos;
         this.craftingItemsToDisplay[WhichTab].Add(Button);
     }
     else
     {
         throw new Exception("Tab: " + WhichTab + " doesn't exist!");
     }
 }
예제 #3
0
 public void SetButton(CraftingRecipeButton button)
 {
     if (recipe != null)
     {
         recipe = null;
         craftButton.gameObject.GetComponent <Image>().sprite = buttonNormal;
         if (craftButton == button.gameObject.GetComponent <Button>())
         {
             craftButton = null;
             return;
         }
     }
     recipe = button.recipe;
     max    = Mathf.Min(button.maxQuantity, recipe.craftedItem.maxQuantity);
     if (quantity > max)
     {
         quantity = max;
     }
     qtext.text  = quantity.ToString();
     craftButton = button.gameObject.GetComponent <Button>();
     craftButton.gameObject.GetComponent <Image>().sprite = buttonSelect;
 }