示例#1
0
        public void SetUp()
        {
            var go = new GameObject(string.Format("TestObject-{0}", DateTime.Now.Millisecond));

            _inventory = go.AddComponent <Inventory>();
            _lookup    = go.AddComponent <MockProductLookup>();

            _lookup.AddProduct(new Product {
                Category = ProductCategory.Raw, ID = ProductId, Name = ProductName
            });

            _scriptable                  = ScriptableObject.CreateInstance <InventoryScriptable>();
            _scriptable.Products         = new List <ProductEntryInfo>();
            _scriptable.Placeables       = new List <string>();
            _scriptable.ProductMaxAmount = MaxAmount;
            _inventory.BindToScriptable(_scriptable, _lookup);

            _reserve = new InventoryReserve();
            _reserve.Initialize(_inventory);
            _reserve.AddReservation(ProductId, 0, false, false);
        }
示例#2
0
        // centralized inventory for the station
        private void InstantiateInventory()
        {
            var go = new GameObject();

            go.transform.SetParent(_layers[LayerType.Core].transform);
            go.name    = "inventory";
            _inventory = go.GetOrAddComponent <Inventory>();
            if (_inventory == null || _inventoryScriptable == null)
            {
                throw new UnityException("Station inventory missing a dependency");
            }
            _inventory.transform.SetParent(transform);
            _inventory.BindToScriptable(_inventoryScriptable, _productLookup, true);

            var product = _productLookup.GetProduct("Credits");

            _inventory.SetProductMaxAmount(product.ID, 1000000);

            product = _productLookup.GetProduct("Energy");
            _inventory.SetProductMaxAmount(product.ID, 1000000);

            _inventoryReserve = new InventoryReserve();
            _inventoryReserve.Initialize(_inventory);
        }