Пример #1
0
        public static void SendKey(Keys key)
        {
            if (key == Keys.E)
            {
                InventoryPanel.Close();
            }

            if (Player.instance.Inventory.Count > 0 && _instance != null)
            {
                if (_instance.Controls != null)
                {
                    foreach (var btn in _instance.Controls)
                    {
                        (btn as ItemButton).FlatAppearance.BorderSize = 0;
                    }
                }

                if (key == Keys.Up)
                {
                    _selectedItem = (_selectedItem - 10).Normalize() % Player.instance.Inventory.Count;
                    (_instance.Controls[_selectedItem] as ItemButton).Select();
                }
                if (key == Keys.Down)
                {
                    _selectedItem = (_selectedItem + 10).Normalize() % Player.instance.Inventory.Count;
                    (_instance.Controls[_selectedItem] as ItemButton).Select();
                }
                if (key == Keys.Left)
                {
                    _selectedItem = (_selectedItem - 1).Normalize() % Player.instance.Inventory.Count;
                    (_instance.Controls[_selectedItem] as ItemButton).Select();
                }
                if (key == Keys.Right)
                {
                    _selectedItem = (_selectedItem + 1).Normalize() % Player.instance.Inventory.Count;
                    (_instance.Controls[_selectedItem] as ItemButton).Select();
                }

                if (key == Keys.Q)
                {
                    (_instance.Controls[_selectedItem] as ItemButton).Item.Use();

                    Close();
                }
            }
        }