public AddInventoryItem ( Ingredient ingredient, int count ) : void | ||
ingredient | Ingredient | |
count | int | |
return | void |
public IEnumerator HarvestCoroutine() { harvestButton.enabled = false; Inventory inventory = UIManager.GetMenu <Inventory>(); float desiredTime = 1f; switch (myTier) { case Tier.first: desiredTime = 5f; break; case Tier.second: desiredTime = 10f; break; case Tier.third: desiredTime = 15f; break; default: break; } desiredTime = Mathf.Clamp(desiredTime - player.Stats.HarvestSpeed, 0f, 10f); float elapsedTime = 0f; while (elapsedTime < desiredTime) { fillIcon2.fillAmount = 1 - (elapsedTime / desiredTime); elapsedTime += Time.deltaTime; yield return(null); } fillIcon2.fillAmount = 1; int val = ingredient.amount; ingredient.amount = Mathf.RoundToInt(Random.Range(val - variance, val + variance)); inventory.AddInventoryItem(ingredient.ingredient, ingredient.amount); ingredient.amount = val; if (Random.Range(0f, 1f) < RareDropChance) { inventory.AddInventoryItem(rareIngredient.ingredient, rareIngredient.amount); } if (!inventory.IsActive) { inventory.Open(); } harvestButton.enabled = true; }
public void OpenTransferModal() { Inventory inventory = UIManager.GetMenu <Inventory>(); Container container = UIManager.GetMenu <Container>(); TransferModal transferModal = UIManager.GetMenu <TransferModal>(); int amount = 0; //TODO remove duplicated code!! if (toInventory) { //we need to add to the inventory amount = container.GetIngredientAmount(inventoryIngredient.ingredient); if (amount > 5) { //open the modal, theres a bunch of things. transferModal = UIManager.GetMenu <TransferModal>(); transferModal.Open(amount, inventoryIngredient, toInventory); Close(); } else { //we just need to throw one over Debug.Log("container -> inventory"); if (amount == 1) { Close(); } inventory.AddInventoryItem(inventoryIngredient.ingredient, 1); container.RemoveInventoryItem(inventoryIngredient.ingredient, 1); } } else { //we need to add to the container amount = inventory.GetIngredientAmount(inventoryIngredient.ingredient); if (amount > 5) { //open the modal, theres a bunch of things. transferModal = UIManager.GetMenu <TransferModal>(); transferModal.Open(amount, inventoryIngredient, toInventory); Close(); } else { //we just need to throw one over Debug.Log("inventory -> container"); if (amount == 1) { Close(); } inventory.RemoveInventoryItem(inventoryIngredient.ingredient, 1); container.AddInventoryItem(inventoryIngredient.ingredient, 1); } } }
private void OpenTransferToolTip() { Inventory inventory = UIManager.GetMenu <Inventory>(); Container container = UIManager.GetMenu <Container>(); if (amount > 5) { //need to pull up a modal } else { //throw one over inventory.AddInventoryItem(SlotIngredient, 1); container.RemoveInventoryItem(SlotIngredient, 1); } CloseHoverTooltip(); }
public void Transfer() { Inventory playerInventory = UIManager.GetMenu <Inventory>(); Container container = UIManager.GetMenu <Container>(); if (toInventory) { playerInventory.AddInventoryItem(ingredient, Mathf.RoundToInt(slider.value)); container.RemoveInventoryItem(ingredient, Mathf.RoundToInt(slider.value)); Close(); } else { playerInventory.RemoveInventoryItem(ingredient, Mathf.RoundToInt(slider.value)); container.AddInventoryItem(ingredient, Mathf.RoundToInt(slider.value)); Close(); } }