Exemple #1
0
        internal void LoadCommon(IHUDTheme Theme = null)
        {
            if (Theme != null)
            {
                theme = Theme;
            }

            Viewport v = This.Game.GraphicsDevice.Viewport;

            scroller     = new TextScroller("scroller", theme);
            scroller.Pos = new Vector2(FrostbyteLevel.BORDER_WIDTH / 2,
                                       v.Height - scroller.GetAnimation().Height);
            scroller.Static = true;

            fader        = new TextFader("fader", theme);
            fader.Pos    = new Vector2(v.Width - 10, v.Height - 10 - 30);
            fader.Anchor = Orientations.Up_Right;
            fader.Static = true;

            #region ItemBag
            items        = new ItemArea("Items", theme);
            items.Pos    = new Vector2(890, 10);
            items.Static = true;
            #endregion
        }
Exemple #2
0
        internal void LoadCommon(IHUDTheme Theme = null)
        {
            if (Theme != null)
            {
                theme = Theme;
            }

            Viewport v = This.Game.GraphicsDevice.Viewport;
            scroller = new TextScroller("scroller", theme);
            scroller.Pos = new Vector2(FrostbyteLevel.BORDER_WIDTH / 2,
                v.Height - scroller.GetAnimation().Height);
            scroller.Static = true;

            fader = new TextFader("fader", theme);
            fader.Pos = new Vector2(v.Width - 10, v.Height - 10 - 30);
            fader.Anchor = Orientations.Up_Right;
            fader.Static = true;

            #region ItemBag
            items = new ItemArea("Items", theme);
            items.Pos = new Vector2(890, 10);
            items.Static = true;
            #endregion
        }
Exemple #3
0
        protected override void OnInput(PointerInput input)
        {
            base.OnInput(input);

            switch (input.State)
            {
            case InputState.Pressed:
                if (ItemArea.Contains(input.Position.ToPoint()))
                {
                    int  offset   = 0;
                    bool selected = false;
                    for (int i = 0; i < Inventory.Items.Count; ++i)
                    {
                        var rect = new Rectangle(ItemArea.X + 2, ItemArea.Y + 2 + offset, ItemArea.Width - 4, selectedItem == i ? ITEM_HEIGHT_OPENED : ITEM_HEIGHT_CLOSED);
                        if (rect.Contains(input.Position.ToPoint()))
                        {
                            selected = true;
                            if (selectedItem == i)
                            {
                                var buttonSize = new Point((rect.Width / 3 - 12), (int)(ITEM_HEIGHT_OPENED - ITEM_HEIGHT_CLOSED - 8));
                                if (new Rectangle(rect.Right - 2 - buttonSize.X, rect.Bottom - 2 - buttonSize.Y, buttonSize.X, buttonSize.Y).Contains(input.Position.ToPoint()))
                                {
                                    //Drop
                                    Inventory.DropItem(i);
                                    selectedItem = -1;
                                }
                                else if (Inventory.Items[i].Usable && new Rectangle(rect.Center.X - buttonSize.X / 2, rect.Bottom - 2 - buttonSize.Y, buttonSize.X, buttonSize.Y).Contains(input.Position.ToPoint()))
                                {
                                    //Use
                                }
                                else if (Inventory.Items[i].Slot != EquipSlot.None && new Rectangle(rect.Left + 2, rect.Bottom - 2 - buttonSize.Y, buttonSize.X, buttonSize.Y).Contains(input.Position.ToPoint()))
                                {
                                    //Equip
                                    Inventory.EquipItem(i);
                                    selectedItem = -1;
                                }
                            }
                            else
                            {
                                selectedItem = i;
                            }
                            break;
                        }
                        offset += 2 + (selectedItem == i ? ITEM_HEIGHT_OPENED : ITEM_HEIGHT_CLOSED);
                    }
                    if (!selected)
                    {
                        selectedItem = -1;
                    }
                }
                else
                {
                    bool selected = false;
                    for (int i = 0; i < Inventory.Equip.Length; ++i)
                    {
                        if (EquipArea(i).Contains(input.Position.ToPoint()))
                        {
                            selected = true;
                            if (Inventory.Equip[i] != null)
                            {
                                selectedEquip = i;
                            }
                            else
                            {
                                selectedEquip = -1;
                            }
                        }
                    }

                    if (!selected && selectedEquip >= 0)
                    {
                        if (EquipButtons(0).Contains(input.Position.ToPoint()))
                        {
                            Inventory.UnequipItem(selectedEquip);
                        }

                        /*else if (Player.Inventory.Equip[selectedEquip].Usable && equipButtons[1].Contains(input.Position))
                         * {
                         *  //Player.Inventory.UseItemFromInventory
                         * }*/
                        else if (EquipButtons(2).Contains(input.Position.ToPoint()))
                        {
                            //Inventory.DropEquip(selectedEquip);
                        }
                        selectedEquip = -1;
                    }
                }
                break;
            }
        }