예제 #1
0
    private void Update()
    {
        if (gameManagerMaster.isGamePaused || gameManagerMaster.isGameOver)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            if (itemDetector.collider)
            {
                Bonfire b = itemDetector.collider.GetComponent <Bonfire>();
                if (b)
                {
                    if (inventory.GetTotalItemCount(wood) > 0)
                    {
                        inventory.RemoveItem(wood, 1);
                        b.Refuel(1);
                        Balloon text = Instantiate(balloon, Camera.main.WorldToScreenPoint(transform.position), Quaternion.identity, balloonParent.transform).GetComponent <Balloon>();
                        text.SetText("-1 " + wood.name);
                    }
                }
            }
        }
    }
예제 #2
0
    public void Craft(RecipeObject recipe)
    {
        //Debug.Log("Trying to craft");
        for (int i = 0; i < recipe.ingredients.Length; i++)
        {
            if (playerInventory.GetTotalItemCount(recipe.ingredients[i].item) < recipe.ingredients[i].quantity)
            {
                return;
            }
        }

        for (int i = 0; i < recipe.ingredients.Length; i++)
        {
            playerInventory.RemoveItem(recipe.ingredients[i].item, recipe.ingredients[i].quantity);
        }

        playerInventory.AddItem(recipe.product.item, recipe.product.quantity);
        Debug.Log("Crafted " + recipe.product.item.name);
    }