示例#1
0
        public ItemSpriteViewerPanel(Genus2D.GameData.ItemData itemData)
        {
            _itemData = itemData;

            _sprite             = null;
            this.AutoScroll     = true;
            this.DoubleBuffered = true;
        }
示例#2
0
        public EditEquipableSpriteForm(EditorForm editor, Genus2D.GameData.ItemData itemData)
        {
            Insance = this;

            InitializeComponent();
            _editor   = editor;
            _itemData = itemData;

            _spriteViewerPanel      = new ItemSpriteViewerPanel(_itemData);
            _spriteViewerPanel.Size = SpriteViewerPanel.Size;
            SpriteViewerPanel.Controls.Add(_spriteViewerPanel);

            PopulateSpriteSelections();
            PopulateDirectionSelections();
            SetAnchors();
        }
示例#3
0
        public int AddInventoryItem(int itemID, int count)
        {
            if (count < 1 || itemID < 0)
            {
                return(0);
            }

            ItemData data = ItemData.GetItemData(itemID);

            if (data == null)
            {
                return(0);
            }
            int max         = data.GetMaxStack();
            int added       = 0;
            int amountToAdd = count;

            for (int i = 0; i < _inventory.Count; i++)
            {
                if (_inventory[i].Item1 == itemID)
                {
                    if (_inventory[i].Item2 < max)
                    {
                        int amountCanAdd = max - _inventory[i].Item2;
                        if (amountToAdd <= amountCanAdd)
                        {
                            _inventory[i] = new Tuple <int, int>(itemID, _inventory[i].Item2 + amountToAdd);
                            added        += amountToAdd;
                            amountToAdd   = 0;
                        }
                        else
                        {
                            _inventory[i] = new Tuple <int, int>(itemID, _inventory[i].Item2 + amountCanAdd);
                            added        += amountCanAdd;
                            amountToAdd  -= amountCanAdd;
                        }
                    }
                }

                if (amountToAdd < 1)
                {
                    break;
                }
            }

            while (amountToAdd > 0)
            {
                if (_inventory.Count < InventorySize)
                {
                    if (amountToAdd <= max)
                    {
                        _inventory.Add(new Tuple <int, int>(itemID, amountToAdd));
                        added += amountToAdd;
                        break;
                    }
                    else
                    {
                        _inventory.Add(new Tuple <int, int>(itemID, max));
                        added       += max;
                        amountToAdd -= max;
                    }
                }
                else
                {
                    break;
                }
            }

            return(added);
        }