public void TearDown() { _inventory = null; _lookup = null; _scriptable = null; _reserve = null; }
public void BindToInventory(Inventory inventory, InventoryScriptable inventoryScriptable, PlaceablesLookup placeablesLookup, InventoryReserve inventoryReserve) { _inventory = inventory; _inventory.OnProductsChanged += UpdateProductEntry; _placeablesLookup = placeablesLookup; _inventoryReserve = inventoryReserve; InitializePlacer(); UpdateIgnoreList(inventoryScriptable); BindToUI(); }
public void Initialize(Inventory inventory, InventoryReserve reserve) { _inventory = inventory; _worldClock = WorldClock.Instance; _worldClock.OnDayUp += CheckForTrade; _reserve = reserve; BindToTrader(); _valueLookup = ProductValueLookup.Instance; MessageHub.Instance.QueueMessage(ProductTrader.MessageName, new TraderInstanceMessageArgs { Trader = _trader }); _creditsProductId = ProductLookup.Instance.GetProduct("Credits").ID; }
public void Initialize(InventoryReserve reserve, int productId, int maxAmount) { _reserve = reserve; _productId = productId; var current = _reserve.GetProductStatus(_productId); if (current == null) { _reserve.AddReservation(_productId, 0, false, false); } BuyToggle.onValueChanged.AddListener(HandleBuyChanged); SellToggle.onValueChanged.AddListener(HandleSellChanged); Slider.minValue = 0; Slider.maxValue = maxAmount; Slider.onValueChanged.AddListener(HandleAmountChanged); }
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); }
// 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); }