private Action <DraggableObjectBehavior> GetAction(InventoryChangeType changeType) { if (changeType == InventoryChangeType.Added) { return(Attach); } if (changeType == InventoryChangeType.Removed) { return(Detach); } return(null); }
/// <summary> /// Listen for changes to the players inventory and act /// </summary> /// <param name="itemGuid">Reference ID for the Item Database</param> /// <param name="change">Type of change that occurred. This could be extended to handle drop logic.</param> private void GameController_OnInventoryChanged(string[] itemGuid, InventoryChangeType change) { //Loop through each item and if it has been picked up, add it to the next empty slot foreach (string item in itemGuid) { if (change == InventoryChangeType.Pickup) { var emptySlot = InventoryItems.FirstOrDefault(x => x.ItemGuid.Equals("")); if (emptySlot != null) { emptySlot.HoldItem(GameController.GetItemByGuid(item)); } } } }
public InventoryChangeData(T item, InventoryChangeType changeType) { Item = item; ChangeType = changeType; }
public ChangeData(string id, InventoryChangeType changeType) { ID = id; ChangeType = changeType; }
public static void ChangeInventory(InventoryChangeType inventoryChangeType, InventoryItemIdentity itemIDToChange, int QTYToChangeBy) { switch (inventoryChangeType) { case InventoryChangeType.Add: if (inventory.ContainsKey(itemIDToChange)) { inventory[itemIDToChange] += QTYToChangeBy; } else { inventory.Add(itemIDToChange, QTYToChangeBy); } if (inventory[itemIDToChange] > 100) { inventory[itemIDToChange] = 100; } break; case InventoryChangeType.Subtract: if (inventory.ContainsKey(itemIDToChange)) { inventory[itemIDToChange] -= QTYToChangeBy; if (!(inventory[itemIDToChange] > 0)) { inventory.Remove(itemIDToChange); } } break; } }