private void Button_Click(object sender, RoutedEventArgs e)
        {
            item = ((Items)playerItemsLeft.SelectedItem);

            if (playerRight.currentItems.Count <= 9 && playerRight.currentItems.Count >= 0)
            {
                if (item != null)
                {
                        playerRight.addToInventory(item);
                        playerLeft.removeFromInventory((byte)playerItemsLeft.SelectedIndex);
                }
                else
                {
                    MessageBox.Show("Left, what are you giving?");
                }
            }
            else
            {
                MessageBox.Show("Sorry, your inventory is full!");
            }
        }
Beispiel #2
0
 public void removeFromInventory(Items item)
 {
     currentItems.Remove(item);
 }
Beispiel #3
0
 public void addToInventory(Items item)
 {
     currentItems.Add(item);
 }
        private void GiveToLeftName_Click(object sender, RoutedEventArgs e)
        {
            selectedItemIndexes = new List<Items>();

            foreach (object o in playerItemsRight.SelectedItems)
            {
                selectedItemIndexes.Add((Items)o);
            }
            initialval = playerItemsLeft.SelectedItems.Count;
            invcheck = playerLeft.currentItems.Count + playerItemsRight.SelectedItems.Count;

            if (playerItemsRight.SelectedItem == null)
            {
                MessageBox.Show("Please select and item to give!");
            }
            else
            {
                if (invcheck <= 10 && invcheck >= 0)
                {

                    for (int i = 0; i < initialval; i++)
                    {
                        item = (Items)playerItemsRight.SelectedItems[0];
                        playerLeft.addToInventory(item);
                        playerRight.removeFromInventory(selectedItemIndexes[i]);
                    }
                }
                else
                {
                    MessageBox.Show(playerLeft.name + " does not have enough space in their inventory!");
                }
            }
        }