// Called when the item is pressed public void UseItem() { //Debug.Log("Pressed left click."); if (item != null) { item.Use(); nameText.text = item.name; descriptionText.text = item.description; if (item.droppable) { canvasController.TurnOnActionCanvas("Poser"); } Debug.Log(toolsManager); toolsManager.CarryItem(true, item); } else { Inventory.instance.usedItem = null; // no item is used canvasController.TurnOffActionCanvas(); toolsManager.CarryItem(false); nameText.text = ""; descriptionText.text = ""; } }
private void Update() { if (Input.GetButtonDown("Action") && isInContact && !hasAnObject && !toolsManager.usingATool) { toolsManager.UseTool(); // Animation toolsManager.GetComponent <Animator>().SetBool("pickUp", true); StartCoroutine("ItemInPipe"); Inventory.instance.Remove(Inventory.instance.usedItem); if (Inventory.instance.usedItem == null) { toolsManager.CarryItem(false); } toolsManager.ActivateActionInfo("Poser", requiredUsingTools, "l'item"); } }
// Remove an item public void RemoveAll(Item item) { items.Remove(item); Debug.Log("RemoveAll"); Debug.Log(usedItem.amount <= 0); if (usedItem.amount <= 0) { usedItem = null; if (toolsManager == null) { toolsManager = GameObject.FindGameObjectWithTag("Player").GetComponent <ToolsManager>(); } if (toolsManager != null) { toolsManager.CarryItem(false); } } if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } }
private void Update() { if (isFacingWater) { toolManager.canDrop = false; toolManager.ActivateActionInfo(actionName, 1, requiredToolName); if (Inventory.instance.isUsingTool(requiredToolName)) { if (Input.GetButtonUp("Action") && !toolManager.usingATool) { GetComponentInParent <PlayerMovement>().animator.SetBool("pickUp", true); toolManager.StartCoroutine("UseTool"); toolManager.CarryItem(true, filledRecipient); Inventory.instance.RemoveByName(requiredToolName); Inventory.instance.Add(filledRecipient); Inventory.instance.ChangeActiveTool(filledRecipient); toolManager.DeactivateActionInfo(); } } } }
private void Update() { if (isInContact) { toolsManager.ActivateActionInfo(actionName, 1, requiredToolName, null); if (Inventory.instance.isUsingTool(requiredToolName)) { if (Input.GetButtonUp("Action") && !toolsManager.usingATool) { toolsManager.StartCoroutine("UseTool"); Inventory.instance.RemoveByName(requiredToolName); Inventory.instance.Add(emptyRecipient); Inventory.instance.ChangeActiveTool(emptyRecipient); ChangeAnimation(); player.transform.LookAt(new Vector3(transform.position.x, player.transform.position.y, transform.position.z)); toolsManager.CarryItem(true, emptyRecipient); toolsManager.DeactivateActionInfo(); } } } }
private void Update() { if (isInContact && Input.GetButtonDown("Action") && !toolsManager.usingATool) { toolsManager.UseTool(); // Animation toolsManager.GetComponent <Animator>().SetBool("pickUp", true); if (nestIsEmpty) { // Put Egg in center //egg = Instantiate(Inventory.instance.usedItem.prefab, eggPosition.position, eggPosition.rotation, eggPosition); egg = Instantiate(Inventory.instance.usedItem.prefab, eggPosition); egg.GetComponent <Rigidbody>().isKinematic = true; egg.GetComponent <ItemPickup>().canPickUp = false; egg.transform.position = eggPosition.position; Inventory.instance.Remove(Inventory.instance.usedItem); if (Inventory.instance.usedItem == null) { toolsManager.CarryItem(false); } // Change Symbol aspect according to egg color mySymbol.myEgg = egg.GetComponent <ItemPickup>().item.name; mySymbol.changeColor(egg.GetComponent <ItemPickup>().item.name); if (mySymbol.CheckWin()) { GetComponent <CinematicTrigger>().Play(); ChangeAnimation(); win = true; } nestIsEmpty = false; toolsManager.ActivateActionInfo("Prendre", null, "Oeuf"); } else { egg.GetComponent <ItemPickup>().canPickUp = true; egg.GetComponent <Rigidbody>().isKinematic = false; Destroy(eggPosition.GetChild(0).gameObject); Inventory.instance.Add(egg.GetComponent <ItemPickup>().item); // Change Symbol aspect according to egg color mySymbol.myEgg = null; mySymbol.setDefaultColor(); // reverse animation only if the door was open before if (win) { GetComponent <CinematicTrigger>().Play(); ChangeAnimation(); win = false; } nestIsEmpty = true; toolsManager.ActivateActionInfo("Poser", requiredUsingTools, "Oeuf"); } } }