public void StartDrag(int index) { if (Slots.ContainsKey(index)) { Slots[index].Highlight(); } }
public bool Drag(DraggableItem item, int amount, GUIComponent slot, out DraggableItem itemDraggedTo, out bool wasNew) { if (!Slots.ContainsKey(slot)) { DraggableItem currentItem = new DraggableItem(item.GUI, slot, new GItem(item.Item.ResourceType, item.Item.Image, item.Item.Tint, item.Item.MinAmount, item.Item.MaxAmount, item.Item.CurrentAmount, item.Item.Price)); GItem gItem = currentItem.Item; if (gItem.CurrentAmount + amount <= gItem.MaxAmount) { gItem.CurrentAmount += amount; } Slots[slot] = currentItem; itemDraggedTo = currentItem; wasNew = false; return(true); } else { DraggableItem currentItem = Slots[slot]; if (currentItem != null) { GItem gItem = currentItem.Item; if (gItem.Name != item.Item.Name) { wasNew = false; itemDraggedTo = null; return(false); } else { if (gItem.CurrentAmount + amount <= gItem.MaxAmount) { gItem.CurrentAmount += amount; wasNew = false; itemDraggedTo = currentItem; return(true); } } } else { DraggableItem ditem = new DraggableItem(item.GUI, slot, new GItem(item.Item.ResourceType, item.Item.Image, item.Item.Tint, item.Item.MinAmount, item.Item.MaxAmount, 0, item.Item.Price)); Slots[slot] = ditem; ditem.LocalBounds = new Rectangle(0, 0, 32, 32); ditem.Item.CurrentAmount += amount; itemDraggedTo = ditem; wasNew = true; return(true); } wasNew = false; itemDraggedTo = null; return(false); } }
private Slot GetSlot(int slotNumber) { if (slotNumber > Max_CAPACITY || slotNumber <= 0) { throw new Exception("Invalid slot number given for slot"); } if (!Slots.ContainsKey(slotNumber)) { Slots.Add(slotNumber, new Slot(slotNumber)); } return(Slots[slotNumber]); }
public static T Resolve <T>(string key, Func <T> factory) { if (Slots.ContainsKey(key) == false) { Slots[key] = Thread.AllocateNamedDataSlot(key); var factoryVal = factory(); Thread.SetData(Slots[key], factoryVal); } var value = Thread.GetData(Slots[key]); return((T)value); }
public void OnInventory(int index) { if (index != CurrentSelected) { if (Slots.ContainsKey(index)) { Slots[index].Use(); } else { UnityEngine.Debug.LogError("Inventory not contains slot: " + index); } } }
public void InitItem(List <SaveItem> items) { foreach (var item in items) { if (Slots.ContainsKey(item.Index)) { Slots[item.Index].SetItem(ItemSpawner.GetItem(item.ID), item.Count); } else { UnityEngine.Debug.LogError("Inventory not contains slot: " + item.Index); } } }
public bool Check(CommandContent content) { if (content.AlexaCommandContent?.IntentName != null) { return(IntentName == content.AlexaCommandContent.IntentName); } if (Slots == null || content.AlexaCommandContent?.Slots == null) { return(false); } return(content.AlexaCommandContent.Slots.Keys.All(key => Slots.ContainsKey(key))); }
public void EndDrag(int index) { if (index == CurrentSelected) { if (Slots.ContainsKey(index)) { Slots[index].OffHighlight(string.Empty); } CurrentSelected = -1; return; } if (Slots.ContainsKey(index)) { Slots[index].OffHighlight(string.Empty); if (Slots.ContainsKey(CurrentSelected)) { Slots[CurrentSelected].OffHighlight(string.Empty); if (Slots[CurrentSelected].IsEmpty) { Slots[CurrentSelected].SetItem(Slots[index].Item, Slots[index].Count); Slots[index].SetItem(null, 0); } else { if (Slots[index].ItemID == Slots[CurrentSelected].ItemID) { if (Slots[CurrentSelected].AddItem(Slots[index].Count)) { OnRemove.Invoke(index, Slots[index].Item.Model); Slots[index].SetItem(null, 0); } } } } else if (CurrentSelected == -1) { Slots[index].SetItem(null, 0); } } else if (Slots.ContainsKey(CurrentSelected)) { Slots[CurrentSelected].OffHighlight(string.Empty); } CurrentSelected = -1; }
public bool AddItem(string id, int index, int count = 1) { if (Slots.ContainsKey(index)) { if (Slots[index].IsEmpty) { Slots[index].SetItem(ItemSpawner.GetItem(id), count); return(true); } else if (Slots[index].ItemID == id) { return(Slots[index].AddItem(count)); } } return(false); }
public bool IsDragValid(DraggableItem item, GUIComponent slot) { if (!Slots.ContainsKey(slot)) { return(true); } else { DraggableItem currentItem = Slots[slot]; GItem gItem = currentItem.Item; if (gItem.Name != item.Item.Name) { return(false); } else { return(true); } } }
public void PurchaseItem(string location) { if (!Slots.ContainsKey(location)) { throw new VendingMachineException("Invalid slot selection."); } if (Slots[location].IsEmpty) { throw new VendingMachineException("Item out of stock."); } if (Slots[location].Price > Trans.BalanceInDollars) { throw new VendingMachineException("Not enough money provided."); } PurchasedItems.Add(GetItemFromSlot(location)); Trans.TotalPurchasePriceInPennies += 100 * GetItemFromSlot(location).Price; log.PrintPurchase(GetItemFromSlot(location).Name, GetItemFromSlot(location).Price, Trans.BalanceInDollars);// purchase log Slots[location].RemoveItem(); }
/// <summary> /// Checks input to see whether slot exists in vending machine. /// </summary> /// <param name="slot"></param> /// <returns></returns> public bool SlotExists(string slot) { return(Slots.ContainsKey(slot)); }
//internal List<string> ListSID() { return zServers.SIDList(-1); } private bool SlotExist(int SlotID) { return(Slots.ContainsKey(SlotID)); }