Example #1
0
 public void Initialize(Texture2D inventoryTexture, ItemPackage itemPackage)
 {
     InventoryTexture = inventoryTexture;
     Quickbar.Items.Items[0] = new Item(itemPackage.ItemTypes[0], 1, true);
     Quickbar.Items.Items[1] = new Item(itemPackage.ItemTypes[2], 255, false);
     Quickbar.Items.Items[2] = new Item(itemPackage.ItemTypes[5], 255, false);
     Quickbar.Items.Items[3] = new Item(itemPackage.ItemTypes[9], 1, true);
     Quickbar.Items.Items[4] = new Item(itemPackage.ItemTypes[8], 20, false);
     Bag.Items.Items[0] = new Item(itemPackage.ItemTypes[3], 10, false);
 }
Example #2
0
        public void Draw(SpriteBatch spriteBatch, Control control, SpriteFont font, ItemPackage itemPackage)
        {
            Quickbar.Draw(spriteBatch, InventoryTexture, itemPackage, font);
            Bag.Draw(spriteBatch, InventoryTexture, itemPackage, font);

            // Dragging Item
            if(HeldItem != null)
            {
                spriteBatch.Draw(itemPackage.ItemTexture, new Rectangle(control.currentMouse.X,control.currentMouse.Y,30,30), HeldItem.Type.Location, Color.White);
                control.ChangeCursor(Control.CursorStates.Custom);
            }
        }
Example #3
0
        protected override void Initialize()
        {

            Player = new Player();
            Map = new Map();
            Chat = new Chat();
            ItemPackage = new ItemPackage();
            WeaponPackage = new WeaponPackage();
            Control = new Control();
            NpcPackage = new NpcPackage();
            Ui = new Ui.Ui();
            Lighting.Initialize();

            base.Initialize();
        }
Example #4
0
        public void Draw(SpriteBatch spriteBatch, Texture2D inventoryTexture, ItemPackage itemPackage, SpriteFont font)
        {
            // Draw Quickbar
            for (int i = 0; i < Size; i++)
            {

                Rectangle current_rect = new Rectangle((int)Area.X + (IncrementX * i), (int)Area.Y + (IncrementY * i), 64, 64);
                spriteBatch.Draw(inventoryTexture, current_rect, new Rectangle(0, 0, 64, 64), Color.White);

                // Draw item
                if (Items.Items[i] != null)
                {
                    Rectangle item_rec = new Rectangle(Items.Items[i].Type.Location.X + 3, Items.Items[i].Type.Location.Y + 3, Items.Items[i].Type.Location.Width - 6, Items.Items[i].Type.Location.Height - 6);
                    spriteBatch.Draw(itemPackage.ItemTexture, current_rect, item_rec, Color.White);
                }

                if (i == MouseOver || i == Selected)
                    spriteBatch.Draw(inventoryTexture, current_rect, new Rectangle(128, 0, 64, 64), Color.White);
                else
                    spriteBatch.Draw(inventoryTexture, current_rect, new Rectangle(64, 0, 64, 64), Color.White);

                // Draw keybindings
                string keybind_string;
                if (i == 9) { keybind_string = "0"; } else { keybind_string = (i + 1).ToString(); }
                TextHelper.DrawString(spriteBatch, font, keybind_string, new Vector2(current_rect.X + 50, current_rect.Y + 5), Color.White, 0.7f);

                if (Items.Items[i] != null && Items.Items[i].Type.Stacksize > 0 && Items.Items[i].Stack > 1)
                {
                    TextHelper.DrawString(spriteBatch, font, Items.Items[i].Stack.ToString(), new Vector2(current_rect.X + 56, current_rect.Y + 48), Color.White, 0.6f, align: "right");
                }
            }
        }
Example #5
0
        public void Draw(SpriteBatch spriteBatch, Texture2D texture, ItemPackage package, SpriteFont font)
        {
            if (Open)
            {

                byte row_upto = 0;
                byte col_upto = 0;
                int offsetx = (spriteBatch.GraphicsDevice.Viewport.Width - (AreaWidth + OffsetX)) / 2;
                int offsety = spriteBatch.GraphicsDevice.Viewport.Height - (AreaHeight + OffsetY);

                foreach (Item item in Items.Items)
                {

                    Rectangle rect = new Rectangle(offsetx + (col_upto * (IconWidth + IconMargin)), offsety + (row_upto * (IconWidth + IconMargin)), IconWidth, IconWidth);

                    spriteBatch.Draw(texture, rect, new Rectangle(0, 0, 64, 64), Color.White);
                    if (item != null)
                    {
                        spriteBatch.Draw(package.ItemTexture, rect, item.Type.Location, Color.White);
                    }
                    col_upto++;
                    if (col_upto >= Width)
                    {
                        row_upto++;
                        col_upto = 0;
                    }
                }

                // Mouse over inventory slot
                if (MouseOver > -1)
                {
                    int col;
                    int row = Math.DivRem(MouseOver, Width, out col);
                    Rectangle rect = new Rectangle(offsetx + (col * (IconWidth + IconMargin)), offsety + (row * (IconWidth + IconMargin)), IconWidth, IconWidth);
                    spriteBatch.Draw(texture, rect, new Rectangle(128, 0, 64, 64), Color.White);
                }

            }
        }