public int Build(ItemTypeObject type, int quantity) { if (_buildingFinished) { return(0); } var requiredItem = _structureType.ConstructionCost.FirstOrDefault(x => x.Type == type); var item = _items.FirstOrDefault(x => x.Type == type); if (requiredItem.Quantity <= item?.Quantity || quantity == 0) { return(0); } if (item == null) { item = new ItemViewModel(type, 0); _items.Add(item); } var maxQuantity = requiredItem.Quantity - item.Quantity; var usedQuantity = maxQuantity > quantity ? quantity : maxQuantity; item.Drop(usedQuantity); _tooltipVm.EditableProperties[type.Name].Value = GetFormattedQuantity(requiredItem); if (!MissingItems.Any()) { StartCoroutine(FinalizeBuilding()); } return(usedQuantity); }
public int Quantity(ItemTypeObject type) { if (_items.ContainsKey(type)) { return(_items[type].Quantity); } return(0); }
public int AvailableSpace(ItemTypeObject type) { var spaceAvailable = (_segment - UsedSegment) * _segmentSize; if (_items.ContainsKey(type)) { spaceAvailable += _segmentSize - _items[type].Quantity % _segmentSize; } return(spaceAvailable); }
public int Pick(ItemTypeObject type, int quantity) { if (!_items.ContainsKey(type)) { return(0); } _items[type].Pick(ref quantity); if (_items[type].Quantity == 0) { _items.Remove(type); } return(quantity); }
public int Add(ItemTypeObject type, int quantity) { var availableSpace = AvailableSpace(type); var dropQuantity = availableSpace < quantity ? availableSpace : quantity; if (_items.ContainsKey(type)) { _items[type].Drop(dropQuantity); } else { _items.Add(type, new ItemViewModel(type, dropQuantity)); } return(quantity - dropQuantity); }
public void SpawnItem(Transform point, ItemTypeObject itemType) { GameObject item = null; switch (itemType) { case ItemTypeObject.PowerItem: item = Instantiate(PowerItem); break; case ItemTypeObject.ScoreItem: item = Instantiate(ScoreItem); break; } var itemTransform = item.transform; SetPosition(point, itemTransform); }
public Item(ItemTypeObject type, int quantity) : this() { _type = type; _quantity = quantity; }
public void Clear() { m_type = null; m_amount = 0; }
public ItemSlot(ItemTypeObject type, int amount) { m_type = type; m_amount = amount; }
public ItemViewModel(ItemTypeObject type, int quantity) { _item = new Item(type, quantity); }
public void JettisonDistant(ItemTypeObject itemType, int quantity) { _distantInventory.Pick(itemType, quantity); }
public void JettisonLocal(ItemTypeObject itemType, int quantity) { _localInventory.Pick(itemType, quantity); }
public void Send(ItemTypeObject itemType, int quantity) { quantity = _localInventory.Pick(itemType, quantity); _distantInventory.Add(itemType, quantity); }