public void draw(SpriteBatch batch, CraftingScreen screen) { if (highlighted) { batch.Draw(Game1.block, currentBounds, Color.Black * .2f); } bool craftable = true; for (int i = 0; i < recepie.components.Length; i++) { Item item = recepie.components[i]; int cost = recepie.costs[i]; Color color = Color.White; if (screen.player.inventory.getItemOfType(item) == null || screen.player.inventory.getItemOfType(item).uses < cost) { color = Color.Red; craftable = false; } Rectangle itemRect = new Rectangle( arrowStartX - 40 - 40 * i, currentBounds.Y + currentBounds.Height / 2 - item.texture.Height / 2, item.texture.Width, item.texture.Height ); batch.Draw(item.texture, itemRect, color); batch.DrawString(Game1.gamefont_24, "" + Game1.decimalToBase6(cost), itemRect.Location.ToVector2() + new Vector2(-20, -20), color); } Color outputColor = Color.White; if (!craftable) { outputColor = Color.Red; } batch.Draw(Game1.UIInventory_Arrow, new Rectangle( arrowStartX, currentBounds.Y + currentBounds.Height / 2 - Game1.UIInventory_Arrow.Height / 2, Game1.UIInventory_Arrow.Width, Game1.UIInventory_Arrow.Height), outputColor); Rectangle outputRect = new Rectangle( arrowStartX + 25 + Game1.UIInventory_Arrow.Width, currentBounds.Y + currentBounds.Height / 2 - recepie.output.texture.Height / 2, recepie.output.texture.Width, recepie.output.texture.Height ); batch.Draw(recepie.output.texture, outputRect, outputColor); batch.DrawString(Game1.gamefont_24, "" + Game1.decimalToBase6(recepie.output.uses), outputRect.Location.ToVector2() + new Vector2(-20, -20), outputColor); }
public CraftingMenuEntry(CraftingScreen screen, CraftingRecepie recepie) { this.recepie = recepie; resultStartX = (int)(screen.craftingRectangle.X + screen.craftingRectangle.Width * .1f); arrowStartX = (int)(screen.craftingRectangle.X + screen.craftingRectangle.Width * .6f); highlighted = false; craftable = true; for (int i = 0; i < recepie.components.Length; i++) { Item item = recepie.components[i]; int cost = recepie.costs[i]; if (screen.player.inventory.getItemOfType(item) == null || screen.player.inventory.getItemOfType(item).uses < cost) { craftable = false; } } }
public void update(CraftingScreen screen, Point mousePos, int slotNumber) { baseBounds = new Rectangle( (int)(screen.craftingRectangle.X + screen.craftingRectangle.Width * .05f), (int)(screen.craftingRectangle.Y + screen.craftingRectangle.Height * .05f) + screen.craftingEntryHeight * slotNumber, (int)(screen.craftingRectangle.Width * .9f), (int)(screen.craftingEntryHeight) ); currentBounds = new Rectangle(baseBounds.X, baseBounds.Y + screen.craftingMenuOffset, baseBounds.Width, baseBounds.Height); if (containsPoint(mousePos)) { highlighted = true; } else { highlighted = false; } }