Пример #1
0
 public void RemoveActiveItem()
 {
     if ( ItemList.ContainsKey( activeItemButton.Item.TypeId ) )
     {
         int anzahl = 1;
         if(activeItemButton.Item.GetType() == typeof(Munition))
         {
             anzahl = Math.Min(ItemList[activeItemButton.Item.TypeId], ((Munition) activeItemButton.Item).MagazineSize);
         }
         ItemList[activeItemButton.Item.TypeId] -= anzahl;
         activeItemButton.CountString = ItemList[activeItemButton.Item.TypeId]+"";
         if ( ItemList[ activeItemButton.Item.TypeId ] < 1 )
         {
             ItemList.Remove( activeItemButton.Item.TypeId );
             buttonList.Remove( activeItemButton );
             activeItemButton = null;
         }
     }
 }
Пример #2
0
        private void AddButton(Item item)
        {
            var y = (int)((DEFAULT_HEIGHT * buttonList.Count)) + btnPrevious.GetHeight();
            var button = new UIListButton(unscaledWidth, 24, new Vector2(0, y), item, player.GetItemCountFromInventar(item.TypeId));

            button.AddActionListener(this);
            button.AddActionListener(listener);
            buttonList.Add(button);
        }
Пример #3
0
        public void OnMouseDown( UIElement element )
        {
            if ( element == btnPrevious && firsVisibleButtonIndex > 0 )
            {
                firsVisibleButtonIndex--;
            }

            if ( element == btnNext )
            {
                if ( ( firsVisibleButtonIndex + MAX_VISIBLE_BUTTON_COUNT ) < buttonList.Count )
                {
                    firsVisibleButtonIndex++;
                }
            }

            if ( element.GetType() == typeof( UIListButton ) )
            {

                foreach ( UIListButton i in buttonList )
                {
                    i.isActive = false;
                    if ( i == element )
                    {
                        i.isActive = true;
                    }
                }

                if ( activeItemButton != null )
                    activeItemButton.Color = Color.Gray;
                activeItemButton = ( UIListButton ) element;
                activeItemButton.Color = Color.Green;
            }
        }