Пример #1
0
        public InventoryOpen(Game1 game) : base(game.Batch, SpriteSortMode.FrontToBack)
        {
            var factory = game.Services.GetService <ControlsFactory>();

            var root = new ContentControll();

            root.Size = Size;

            var frame = new ContentControll();

            frame.OffsetFrom = Anchors.Center;

            #region inventory
            var items = new WrapContent();
            items.OffsetFrom = Anchors.Center;

            var panel = factory.CreatePanel(4);
            panel.ComputeSize(Vector2.Zero, Autosize.Content);
            panel.OffsetFrom = Anchors.Center;

            items.Size = panel.Size - new Vector2(50);

            inventory            = new InventoryArea(items, factory);
            inventory.OffsetFrom = Anchors.Center;
            inventory.Size       = items.Size;

            #endregion

            #region equipment
            var helmetPanel = factory.CreatePanel(textureName: "ui/equipment/helmet");
            var helmetSlot  = new ItemSlot(helmetPanel, ItemTypeFlags.Helmet);
            helmetSlot.OffsetFrom = Anchors.TopRight;
            helmetSlot.Offset     = new Vector2(50, 0);

            var weaponPanel = factory.CreatePanel(textureName: "ui/equipment/sword");
            var weaponSlot  = new ItemSlot(weaponPanel, ItemTypeFlags.Weapon);
            weaponSlot.OffsetFrom = Anchors.TopRight;
            weaponSlot.Offset     = new Vector2(50, 55);
            #endregion

            frame.Size = panel.Size;
            frame.Children.Add(inventory);
            frame.Children.Add(panel);
            frame.Children.Add(items);
            frame.Children.Add(helmetSlot);
            frame.Children.Add(weaponSlot);

            root.Children.Add(frame);
            Root = root;
        }
Пример #2
0
        public ChestOpen(Game1 game) : base(game.Batch, SpriteSortMode.FrontToBack)
        {
            var factory = game.Services.GetService <ControlsFactory>();

            var root = new ContentControll();

            root.Size = Size;

            var frame = new ContentControll();

            frame.OffsetFrom = Anchors.Center;

            #region left_inventory

            var leftFrame = new ContentControll();

            var leftItems = new WrapContent();
            leftItems.OffsetFrom = Anchors.Center;

            var leftPanel = factory.CreatePanel(4);
            leftPanel.OffsetFrom = Anchors.Center;

            leftItems.Size = leftPanel.Size - new Vector2(50);

            leftInventory            = new InventoryArea(leftItems, factory);
            leftInventory.Size       = leftItems.Size;
            leftInventory.OffsetFrom = Anchors.Center;

            leftFrame.Children.Add(leftPanel);
            leftFrame.Children.Add(leftItems);
            leftFrame.Children.Add(leftInventory);

            leftFrame.Size       = leftPanel.Size;
            leftFrame.OffsetFrom = Anchors.CenterRight;

            #endregion

            #region right_inventory

            var rightFrame = new ContentControll();

            var rightItems = new WrapContent();
            rightItems.OffsetFrom = Anchors.Center;

            var rightPanel = factory.CreatePanel(4);
            rightPanel.OffsetFrom = Anchors.Center;

            rightItems.Size = rightPanel.Size - new Vector2(50);

            rightInventory            = new InventoryArea(rightItems, factory);
            rightInventory.Size       = rightItems.Size;
            rightInventory.OffsetFrom = Anchors.Center;

            rightFrame.Children.Add(rightPanel);
            rightFrame.Children.Add(rightItems);
            rightFrame.Children.Add(rightInventory);
            rightFrame.OffsetFrom = Anchors.CenterLeft;

            rightFrame.Size = rightPanel.Size;

            #endregion

            frame.Children.Add(leftFrame);
            frame.Children.Add(rightFrame);

            root.Children.Add(frame);
            Root = root;
        }