public CraftingInterface(CraftingRecipe recipe, Projectile output, SpriteFont font, int x, int y, int width, int height, OnCraft onCraft, GraphicsDevice graphics) { Output = output; this.font = font; this.onCraft = onCraft; this.graphics = graphics; bgImg = new Texture2D(graphics, width, height); bgImg = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray); bgRect = new Rectangle(x, y, width, height); Output.X = bgRect.X + (bgRect.Width / 2 - (output.Width / 2)); Output.Y = bgRect.Y + SPACING; if (Output.Height > Utilities.LightningHeight * 2) { Output.Height = Utilities.LightningHeight * 2; } materials = recipe.Materials; materialCounts = recipe.MaterialAmounts; int lastXMaterials = bgRect.X + SPACING; for (int i = 0; i < recipe.Materials.Count; i++) { materialImgs.Add(Utilities.GetImgOfMaterial(recipe.Materials[i])); materialRects.Add(new Rectangle(lastXMaterials, output.Y + output.Height + SPACING, MATERIAL_SIZE, MATERIAL_SIZE)); materialCountLocations.Add(new Vector2(materialRects[i].Right - SPACING, materialRects[i].Bottom - SPACING)); lastXMaterials += materialRects[i].Width + (SPACING * 3); } craftButton = new MenuButton(Craft, Language.Translate("Craft"), 0, 0, true, font, graphics); craftButton.CanHold = true; Reposition(); youHave = Language.Translate("You Have") + ": 0"; youHavePos = new Vector2(bgRect.X + (bgRect.Width / 2 - (font.MeasureString(youHave).X / 2)), craftButton.Y - (font.MeasureString(youHave).Y)); }
public void AddOnCraftHandler(OnCraft handler) { itemCrafted += handler; }