private void DropItemInWorld(Item item) { GameObject o = (GameObject)Instantiate(Resources.Load($"Prefabs/Items/{item.ID}")); o.transform.position = GameObject.FindGameObjectWithTag("Player").transform.position; UpdatedInventory?.Invoke(Inventory); }
private void OnAddItem(Item item, int stackSize) { // Find the first available slot, and add the item to it. for (int i = 0; i < Capacity; i++) { if (Inventory[i] == null) { Inventory[i] = new ItemSlot(item, stackSize); break; } else if (Inventory[i].Item.ID == item.ID) { Inventory[i].StackSize += stackSize; break; } } UpdatedInventory?.Invoke(Inventory); }
public async Task Consume(ConsumeContext <InventoryToUpdate> context) { if (context == null) { _logger.LogWarning("Failed to consume Inventory update as context is null"); return; } TruckInventory tid = _mapper.Map <TruckInventory>(context.Message); if (await _service.UpdateTruckInventory(tid)) { TruckInventory newDetails = await _service.GetTruckInventory(tid.TruckId); var eventMessage = new UpdatedInventory(); eventMessage.TruckId = newDetails.TruckId; // eventMessage.TruckName = newDetails.TruckName; eventMessage.NewQuantity = newDetails.Quantity; _logger.LogInformation($"Updated Catalog. New qty for {eventMessage.TruckId} is {eventMessage.NewQuantity}. Name is {eventMessage.TruckName}"); await _publishEndpoint.Publish(eventMessage); } }
// Update is called once per frame void Update() { UpdatedInventory?.Invoke(Inventory); if (Input.GetKeyDown(KeyCode.Alpha1)) { SelectedIndex = 0; } if (Input.GetKeyDown(KeyCode.Alpha2)) { SelectedIndex = 1; } if (Input.GetKeyDown(KeyCode.Alpha3)) { SelectedIndex = 2; } if (Input.GetKeyDown(KeyCode.Alpha4)) { SelectedIndex = 3; } if (Input.GetKeyDown(KeyCode.Alpha5)) { SelectedIndex = 4; } if (Input.GetKeyDown(KeyCode.Alpha6)) { SelectedIndex = 5; } if (Input.GetKeyDown(KeyCode.Alpha7)) { SelectedIndex = 6; } if (Input.GetKeyDown(KeyCode.Alpha8)) { SelectedIndex = 7; } if (Input.GetKeyDown(KeyCode.Alpha9)) { SelectedIndex = 8; } if (Input.GetKeyDown(KeyCode.Alpha0)) { SelectedIndex = 9; } if (Input.mouseScrollDelta.y < 0f) { SelectedIndex--; } if (Input.mouseScrollDelta.y > 0f) { SelectedIndex++; } }