Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public int Quantity(ItemTypeObject type)
 {
     if (_items.ContainsKey(type))
     {
         return(_items[type].Quantity);
     }
     return(0);
 }
Ejemplo n.º 3
0
        public int AvailableSpace(ItemTypeObject type)
        {
            var spaceAvailable = (_segment - UsedSegment) * _segmentSize;

            if (_items.ContainsKey(type))
            {
                spaceAvailable += _segmentSize - _items[type].Quantity % _segmentSize;
            }
            return(spaceAvailable);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
Archivo: Item.cs Proyecto: Tiitan/Boats
 public Item(ItemTypeObject type, int quantity) : this()
 {
     _type     = type;
     _quantity = quantity;
 }
Ejemplo n.º 8
0
 public void Clear()
 {
     m_type   = null;
     m_amount = 0;
 }
Ejemplo n.º 9
0
 public ItemSlot(ItemTypeObject type, int amount)
 {
     m_type   = type;
     m_amount = amount;
 }
Ejemplo n.º 10
0
 public ItemViewModel(ItemTypeObject type, int quantity)
 {
     _item = new Item(type, quantity);
 }
Ejemplo n.º 11
0
 public void JettisonDistant(ItemTypeObject itemType, int quantity)
 {
     _distantInventory.Pick(itemType, quantity);
 }
Ejemplo n.º 12
0
 public void JettisonLocal(ItemTypeObject itemType, int quantity)
 {
     _localInventory.Pick(itemType, quantity);
 }
Ejemplo n.º 13
0
 public void Send(ItemTypeObject itemType, int quantity)
 {
     quantity = _localInventory.Pick(itemType, quantity);
     _distantInventory.Add(itemType, quantity);
 }