コード例 #1
0
        public static void DrawSelf(SpriteBatch spriteBatch)
        {
            UIElementWorkbench.DrawPanel(spriteBatch, UIElementWorkbench._backgroundTexture, new Color(33, 43, 79) * 0.8f);
            UIElementWorkbench.DrawPanel(spriteBatch, UIElementWorkbench._borderTexture, new Color(89, 116, 213) * 0.7f);

            float oldScale = Main.inventoryScale;

            Main.inventoryScale = 0.75f;
            Point value = new Point(Main.mouseX, Main.mouseY);

            Main.spriteBatch.DrawString(Main.fontMouseText,
                                        "Upgrade Workbench", new Vector2(UIElementWorkbench.X + 33, UIElementWorkbench.Y + 10),
                                        Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);

            Rectangle hitbox = new Rectangle(UIElementWorkbench.X + 66, UIElementWorkbench.Y + 180, 50, 18);

            Main.spriteBatch.DrawString(Main.fontMouseText,
                                        "Upgrade", new Vector2(UIElementWorkbench.X + 66, UIElementWorkbench.Y + 180),
                                        Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);


            if (hitbox.Contains(value) && !PlayerInput.IgnoreMouseInterface && Main.mouseLeft && Main.mouseLeftRelease)
            {
                Main.player[Main.myPlayer].mouseInterface = true;
                if (DushyUpgrade.elementWorkbenchTE.itemToEnchant.IsAir) //First case empty
                {
                    Main.NewText("You need an item to upgrade");
                }
                else if (DushyUpgrade.elementWorkbenchTE.elementalScroll.IsAir)
                {
                    Main.NewText("You need an upgrade stone or an upgrade scroll to upgrade");
                }
                else
                {
                    if (!DushyUpgrade.IsItemBroken(DushyUpgrade.elementWorkbenchTE.itemToEnchant))
                    {
                        UpgradeInfo info = DushyUpgrade.elementWorkbenchTE.itemToEnchant.GetGlobalItem <UpgradeInfo>();
                        int         result;
                        result = info.enchantItem(DushyUpgrade.elementWorkbenchTE.itemToEnchant);

                        DushyUpgrade.elementWorkbenchTE.elementalScroll.stack--;

                        ItemText.NewText(Main.player[Main.myPlayer], "Success !", Color.Green);
                    }
                }
            }
            for (int i = 0; i < 3; i++)
            {
                int       x    = UIElementWorkbench.X;
                int       y    = 42 * i + UIElementWorkbench.Y + 40;
                Rectangle r    = new Rectangle(x, y, (int)((float)Main.inventoryBackTexture.Width * Main.inventoryScale), (int)((float)Main.inventoryBackTexture.Height * Main.inventoryScale));
                Item      item = i == 0 ? DushyUpgrade.elementWorkbenchTE.itemToEnchant : DushyUpgrade.elementWorkbenchTE.elementalScroll;

                if (r.Contains(value) && !PlayerInput.IgnoreMouseInterface)
                {
                    Main.player[Main.myPlayer].mouseInterface = true;
                    if (UIElementWorkbench.CanGoInSlot(Main.mouseItem, i))
                    {
                        ItemSlot.Handle(ref item, 3);
                    }
                }
                ItemSlot.Draw(spriteBatch, ref item, 3, new Vector2(x, y));
                switch (i)
                {
                case 0:
                    DushyUpgrade.elementWorkbenchTE.itemToEnchant = item;
                    break;

                case 1:
                    DushyUpgrade.elementWorkbenchTE.elementalScroll = item;
                    break;

                default:
                    break;
                }

                Main.spriteBatch.DrawString(Main.fontMouseText,
                                            UIElementWorkbench.labels[i], new Vector2(x + 48, y + 10),
                                            Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);
            }
            Main.inventoryScale = oldScale;
        }