Esempio n. 1
0
 public DroppableItem(DroppableItem item, int count, IItemContainer startingLocation)
 {
     ItemId   = item.ItemId;
     Name     = item.Name;
     Count    = count;
     Location = startingLocation;
     startingLocation.Add(this);
 }
Esempio n. 2
0
        public void Remove(DroppableItem item)
        {
            if (Item != item)
            {
                throw new Exception("Removing wrong item");
            }

            Item = null;
            Notify("Item");
        }
Esempio n. 3
0
        public int Add(DroppableItem item)
        {
            if (Item != null)
            {
                throw new Exception("Cant equip weapon without removing existing on first");
            }

            Item = item;
            Notify("Item");

            return(1);
        }
Esempio n. 4
0
        public void SetCount(DroppableItem item, int count)
        {
            if (count > 1)
            {
                throw new Exception("Cant be over 1");
            }

            if (count == 0)
            {
                Item = null;
            }
            Notify("Item");
        }
Esempio n. 5
0
        private void OnDroppedItemsAlert(DroppedItemAlert alert)
        {
            var existingItem = DroppedItems.FirstOrDefault(i => i.ItemId == alert.DroppedItem.ItemId);

            if (existingItem != null)
            {
                existingItem.SetCount(existingItem.Count + alert.DroppedItem.Count);
            }
            else
            {
                var item = new DroppableItem(alert.DroppedItem, DroppedItems);
                item.OnItemMoved += OnItemMoved;
            }
            Notify("DroppedItems");
        }
Esempio n. 6
0
        private async void GetInventory()
        {
            var result = await client.SendRequest(new GetInventoryRequest(), player);

            if (result.Success && result.data is InventoryResponse response)
            {
                foreach (var item in response.Inventory)
                {
                    var droppableItem = new DroppableItem(item, Items);
                    droppableItem.OnItemMoved += OnItemMoved;
                }
                foreach (var item in response.DroppedItems)
                {
                    var droppableItem = new DroppableItem(item, DroppedItems);
                    droppableItem.OnItemMoved += OnItemMoved;
                }
                Equipment.EquipAll(response.EquippedItems, OnItemMoved);
            }
            else
            {
                throw new Exception("Got wrong result");
            }
        }
Esempio n. 7
0
 public bool FitsInSlot(DroppableItem item)
 {
     return(item.SlotType != null && item.SlotType == Type);
 }