Пример #1
0
        public void AddItemToInventory(Item itemToAdd, int quantity = 1)
        {
            InventoryItem item = Inventory.SingleOrDefault(ii => ii.Details.ID == itemToAdd.ID);

            if (item == null)
            {
                // They didn't have the item, so add it to their inventory, with a quantity of 1
                Inventory.Add(new InventoryItem(itemToAdd, quantity));
            }
            else
            {
                // They have the item in their inventory, so increase the quantity by one
                item.Quantity += quantity;
            }

            RaiseInventoryChangedEvent(itemToAdd);
        }
Пример #2
0
        public void AddItemToInventory(Item itemToAdd)
        {
            foreach (InventoryItem ii in Inventory)
            {
                if (ii.Details.ID == itemToAdd.ID)
                {
                    // They have the item in their inventory, so increase
                    // the quantity by one
                    ii.Quantity++;

                    return; // We added the item, and are done, so get out
                            // out of this function
                }
            }
            // They didn't have the item, so add it to their inventory,
            // with a quantity of 1
            Inventory.Add(new InventoryItem(itemToAdd, 1));
        }
Пример #3
0
        public void AddItem(Item item, int quantity)
        {
            if (item == null)
            {
                return;
            }
            foreach (InventoryItem inventoryItem in Inventory)
            {
                if (item.ID == inventoryItem.Details.ID)
                {
                    inventoryItem.Quantity += quantity;
                    return;
                }
            }
            InventoryItem newItem = new InventoryItem(item, quantity);

            Inventory.Add(newItem);
        }
Пример #4
0
        public void AddItemToInventory(Item itemToAdd, int quantity = 1)
        {
            if (quantity <= 0)
            {
                return;
            }

            InventoryItem item = Inventory.SingleOrDefault(a => a.Details.ID == itemToAdd.ID);

            if (item == null)
            {
                Inventory.Add(new InventoryItem(itemToAdd, quantity));
            }
            else
            {
                item.Quantity += quantity;
            }
        }
Пример #5
0
        public void AddItemToInventory(Item itemToAdd, int quantity = 1)
        {
            InventoryItem item = Inventory.SingleOrDefault(ii => ii.Details.ID == itemToAdd.ID);

            if (item == null)
            {
                // They didn't have the item, so add it to their inventory
                Inventory.Add(new InventoryItem(itemToAdd, quantity));
            }
            else
            {
                // They have the item in their inventory, so increase the quantity
                item.Quantity += quantity;
            }

            OnPropertyChanged(nameof(Inventory));
            OnPropertyChanged(nameof(VendorGold));
        }
Пример #6
0
 public void AddItemToInventory(Item item)
 {
     Inventory.Add(item);
     if (item.IsUnique)
     {
         GroupedInventory.Add(new InventoryItem(item, 1));
     }
     else
     {
         if (!GroupedInventory.Any(gi => gi.GameItem.ItemID == item.ItemID))
         {
             GroupedInventory.Add(new InventoryItem(item, 0));
         }
         GroupedInventory.First(gi => gi.GameItem.ItemID == item.ItemID).Quantity++;
     }
     OnPropertyChanged(nameof(Weapons));
     OnPropertyChanged(nameof(Armors));
     OnPropertyChanged(nameof(Gloves));
     OnPropertyChanged(nameof(Boots));
 }
Пример #7
0
        public void AddItemToInventory(Item itemToAdd, int quantity = 1)
        {
            InventoryItem item = Inventory.SingleOrDefault(
                ii => ii.Details.ID == itemToAdd.ID);

            if (item == null)
            {
                // Player doesn't have item; add it
                Inventory.Add(new InventoryItem(itemToAdd, quantity));
            }
            else if (itemToAdd.Name == "Trident")
            {
            }
            else
            {
                // Player has it, so increase quantity
                item.Quantity += quantity;
            }

            RaiseInventoryChangedEvent(itemToAdd);
        }
Пример #8
0
        public void winBattle()
        {
            RaiseMessage("You've defeated " + _currentMonster.Name);

            //give player rewards
            AddExperiencePoints(_currentMonster.RewardExperiencePoints);
            AddGold(_currentMonster.RewardGold);

            // Collect chance loot from loot table
            List <LootItem> lootCollected = new List <LootItem>();
            int             rngNumber     = 0;

            foreach (LootItem li in _currentMonster.LootTable)
            {
                rngNumber = Engine.RandomNumberGenerator.NumberBetween(0, 100);
                if (rngNumber <= li.DropPercentage)
                {
                    lootCollected.Add(li);
                }
            }
            /* Make sure player gets at least one item */
            if (lootCollected.Count == 0)
            {
                foreach (LootItem li in _currentMonster.LootTable)
                {
                    if (li.IsDefaultItem)
                    {
                        lootCollected.Add(li);
                        break;
                    }
                }
            }
            foreach (LootItem li in lootCollected)
            {
                bool playerHasItem = false;
                foreach (InventoryItem ii in Inventory)
                {
                    if (ii.Details.ID == li.Details.ID)
                    {
                        ii.Quantity  += 1;
                        playerHasItem = true;
                    }
                }
                if (playerHasItem == false)
                {
                    // player doesn't have it yet, add it to their inventory
                    Inventory.Add(new InventoryItem(li.Details, 1));
                }
                RaiseMessage("You've received " + li.Details.Name + Environment.NewLine);
            }
            // If no items were randomly selected, then add the default loot item(s).

            /*if (lootCollected.Count == 0)
             * {
             *  foreach (LootItem li in _currentMonster.LootTable)
             *  {
             *      if (li.IsDefaultItem)
             *      {
             *          _player.Inventory.Add(new InventoryItem(li.Details, 1));
             *          rtbMessages.Text += "You've received " + li.Details.Name;
             *          break;
             *      }
             *  }
             * }*/
        }
Пример #9
0
 public void AddItem(string name, int quant)
 {
     Inventory.Add(new InventoryItem(name, quant));
 }
Пример #10
0
 public void AddItem(string name)
 {
     Inventory.Add(new InventoryItem(name, 1));
 }